包含的URLconf中没有任何模式

时间:2018-03-21 18:34:10

标签: python django

我正在关注网站上的django教程,当我运行python manage.py runserver时,我遇到了错误。

我的django版本为1.11.1

在我的settings.py文件中,我设置: ROOT_URLCONF = 'SimpleVotingApp.urls'

SimpleVotingApp.urls文件如下所示:

    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),
    ]

我的polls.urls文件如下所示:

from django.conf.urls import url

from . import views

urlPatterns = [
    url(r'^$', views.index, name='index'),
]

运行python manage.py runserver命令时,我不断收到以下错误。



Unhandled exception in thread started by <function wrapper at 0x10f3cb410>
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/django/utils/autoreload.py", line 228, in wrapper
    fn(*args, **kwargs)
  File "/Library/Python/2.7/site-packages/django/core/management/commands/runserver.py", line 124, in inner_run
    self.check(display_num_errors=True)
  File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 359, in check
    include_deployment_checks=include_deployment_checks,
  File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 346, in _run_checks
    return checks.run_checks(**kwargs)
  File "/Library/Python/2.7/site-packages/django/core/checks/registry.py", line 81, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/Library/Python/2.7/site-packages/django/core/checks/urls.py", line 16, in check_url_config
    return check_resolver(resolver)
  File "/Library/Python/2.7/site-packages/django/core/checks/urls.py", line 26, in check_resolver
    return check_method()
  File "/Library/Python/2.7/site-packages/django/urls/resolvers.py", line 255, in check
    warnings.extend(check_resolver(pattern))
  File "/Library/Python/2.7/site-packages/django/core/checks/urls.py", line 26, in check_resolver
    return check_method()
  File "/Library/Python/2.7/site-packages/django/urls/resolvers.py", line 254, in check
    for pattern in self.url_patterns:
  File "/Library/Python/2.7/site-packages/django/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/Library/Python/2.7/site-packages/django/urls/resolvers.py", line 414, in url_patterns
    raise ImproperlyConfigured(msg.format(name=self.urlconf_name))
django.core.exceptions.ImproperlyConfigured: The included URLconf '<module 'polls.urls' from '/Users/my.name/PycharmProjects/SimpleVotingApp/polls/urls.pyc'>' does not appear to have any patterns in it. 
If you see valid patterns in the file then the issue is probably caused by a circular import.
&#13;
&#13;
&#13;

0 个答案:

没有答案