我做了Python的Django的网络app.And我当 我试图运行下面给出的使用python manage.py runserver
项目上urls.py错误是我的错误。导入错误的urls.py在运行的Python Django应用程序
Not Found: /hello
[09/Nov/2016 16:22:34] "GET /hello HTTP/1.1" 404 1920
Performing system checks...
Unhandled exception in thread started by <function wrapper at 0xb68f7924>
Traceback (most recent call last):
File "/home/nishanth/nenv/local/lib/python2.7/site-packages/Django-1.10.3-py2.7.egg/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/home/nishanth/nenv/local/lib/python2.7/site-packages/Django-1.10.3-py2.7.egg/django/core/management/commands/runserver.py", line 121, in inner_run
self.check(display_num_errors=True)
File "/home/nishanth/nenv/local/lib/python2.7/site-packages/Django-1.10.3-py2.7.egg/django/core/management/base.py", line 374, in check
include_deployment_checks=include_deployment_checks,
File "/home/nishanth/nenv/local/lib/python2.7/site-packages/Django-1.10.3-py2.7.egg/django/core/management/base.py", line 361, in _run_checks
return checks.run_checks(**kwargs)
File "/home/nishanth/nenv/local/lib/python2.7/site-packages/Django-1.10.3-py2.7.egg/django/core/checks/registry.py", line 81, in run_checks
new_errors = check(app_configs=app_configs)
File "/home/nishanth/nenv/local/lib/python2.7/site-packages/Django-1.10.3-py2.7.egg/django/core/checks/urls.py", line 14, in check_url_config
return check_resolver(resolver)
File "/home/nishanth/nenv/local/lib/python2.7/site-packages/Django-1.10.3-py2.7.egg/django/core/checks/urls.py", line 24, in check_resolver
for pattern in resolver.url_patterns:
File "/home/nishanth/nenv/local/lib/python2.7/site-packages/Django-1.10.3-py2.7.egg/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/nishanth/nenv/local/lib/python2.7/site-packages/Django-1.10.3-py2.7.egg/django/urls/resolvers.py", line 313, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/nishanth/nenv/local/lib/python2.7/site-packages/Django-1.10.3-py2.7.egg/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/nishanth/nenv/local/lib/python2.7/site-packages/Django-1.10.3-py2.7.egg/django/urls/resolvers.py", line 306, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/nishanth/Documents/register/register/urls.py", line 16, in <module>
from django.conf.urls import patterns, include, url
ImportError: cannot import name patterns
Performing system checks...
这是我的urls.py
from django.conf.urls import patterns, include, url
from django.contrib import admin
urlpatterns = patterns['',
url(r'^admin/', admin.site.urls),
url(r'^hello/$', 'blog.views.hello'),
url(r'^hello_template/$' , 'blog.views.hello_template'),
]
我怎样才能解决这个问题的Django的
如果这个代码来自一个教程,那么它是出的日期。上面的代码是为Django 1.7或更早的版本编写的。如果你开始学习Django,那么请寻找更新的教程,否则你会遇到更多这样的问题。 – Alasdair