运行 Django Environment (for windows) with Tutorial - 遇到很多错误
Run Django Environment (for windows) with Tutorial - getting many errors
我正在设置一个 Django 框架,我正在这样做,使用这个教程:https://docs.djangoproject.com/en/1.9/intro/tutorial01/. And before that I used this Tutorial to get started: https://docs.djangoproject.com/en/1.9/howto/windows/
我基本上完成了页面,当我 运行 命令行中的最后一个命令 'python manage.py runserver' 时,它会得到一个很长的错误列表,见下文。
我已经重复了大约 3 次教程,并且在我的正常 python 环境和虚拟环境中安装了 django。我 运行 'python manage.py runserver' 在每个可能的文件夹中。 - 但我不工作。有人可以告诉我哪里出错了吗?
Microsoft Windows [Version 10.0.10586]
(c) 2015 Microsoft Corporation. Alle Rechte vorbehalten.
C:\Users\Johanna>cd Envs\mysite
C:\Users\Johanna\Envs\mysite>python manage.py runserver
Performing system checks...
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x03A6F198>
Traceback (most recent call last):
File "C:\Program Python\Python35-32\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "C:\Program Python\Python35-32\lib\site-packages\django\core\management\commands\runserver.py", line 116, in inner_run
self.check(display_num_errors=True)
File "C:\Program Python\Python35-32\lib\site-packages\django\core\management\base.py", line 426, in check
include_deployment_checks=include_deployment_checks,
File "C:\Program Python\Python35-32\lib\site-packages\django\core\checks\registry.py", line 75, in run_checks
new_errors = check(app_configs=app_configs)
File "C:\Program Python\Python35-32\lib\site-packages\django\core\checks\urls.py", line 10, in check_url_config
return check_resolver(resolver)
File "C:\Program Python\Python35-32\lib\site-packages\django\core\checks\urls.py", line 19, in check_resolver
for pattern in resolver.url_patterns:
File "C:\Program Python\Python35-32\lib\site-packages\django\utils\functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Program Python\Python35-32\lib\site-packages\django\core\urlresolvers.py", line 417, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Program Python\Python35-32\lib\site-packages\django\utils\functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Program Python\Python35-32\lib\site-packages\django\core\urlresolvers.py", line 410, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Program Python\Python35-32\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 662, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "C:\Users\Johanna\Envs\mysite\mysite\urls.py", line 20, in <module>
url(r'^polls/', include('polls.urls')),
NameError: name 'include' is not defined
确保您在 C:\Users\Johanna\Envs\mysite\mysite\urls.py
中的代码与此完全相同
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
url(r'^polls/', include('polls.urls')),
url(r'^admin/', admin.site.urls),
]
特别是,确保你有最上面的一行from django.conf.urls import include, url
我正在设置一个 Django 框架,我正在这样做,使用这个教程:https://docs.djangoproject.com/en/1.9/intro/tutorial01/. And before that I used this Tutorial to get started: https://docs.djangoproject.com/en/1.9/howto/windows/
我基本上完成了页面,当我 运行 命令行中的最后一个命令 'python manage.py runserver' 时,它会得到一个很长的错误列表,见下文。
我已经重复了大约 3 次教程,并且在我的正常 python 环境和虚拟环境中安装了 django。我 运行 'python manage.py runserver' 在每个可能的文件夹中。 - 但我不工作。有人可以告诉我哪里出错了吗?
Microsoft Windows [Version 10.0.10586]
(c) 2015 Microsoft Corporation. Alle Rechte vorbehalten.
C:\Users\Johanna>cd Envs\mysite
C:\Users\Johanna\Envs\mysite>python manage.py runserver
Performing system checks...
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x03A6F198>
Traceback (most recent call last):
File "C:\Program Python\Python35-32\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "C:\Program Python\Python35-32\lib\site-packages\django\core\management\commands\runserver.py", line 116, in inner_run
self.check(display_num_errors=True)
File "C:\Program Python\Python35-32\lib\site-packages\django\core\management\base.py", line 426, in check
include_deployment_checks=include_deployment_checks,
File "C:\Program Python\Python35-32\lib\site-packages\django\core\checks\registry.py", line 75, in run_checks
new_errors = check(app_configs=app_configs)
File "C:\Program Python\Python35-32\lib\site-packages\django\core\checks\urls.py", line 10, in check_url_config
return check_resolver(resolver)
File "C:\Program Python\Python35-32\lib\site-packages\django\core\checks\urls.py", line 19, in check_resolver
for pattern in resolver.url_patterns:
File "C:\Program Python\Python35-32\lib\site-packages\django\utils\functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Program Python\Python35-32\lib\site-packages\django\core\urlresolvers.py", line 417, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Program Python\Python35-32\lib\site-packages\django\utils\functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Program Python\Python35-32\lib\site-packages\django\core\urlresolvers.py", line 410, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Program Python\Python35-32\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 662, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "C:\Users\Johanna\Envs\mysite\mysite\urls.py", line 20, in <module>
url(r'^polls/', include('polls.urls')),
NameError: name 'include' is not defined
确保您在 C:\Users\Johanna\Envs\mysite\mysite\urls.py
中的代码与此完全相同
from django.conf.urls import include, url from django.contrib import admin urlpatterns = [ url(r'^polls/', include('polls.urls')), url(r'^admin/', admin.site.urls), ]
特别是,确保你有最上面的一行from django.conf.urls import include, url