【发布时间】:2018-02-01 14:16:29
【问题描述】:
我遇到了一个错误:
...
File "/Users/xxx/anaconda/envs/py36/lib/python3.6/site-packages/django/urls/resolvers.py", line 545, in url_patterns
raise ImproperlyConfigured(msg.format(name=self.urlconf_name))
django.core.exceptions.ImproperlyConfigured: The included URLconf '<module 'django.urls' from '/Users/xxx/anaconda/envs/py36/lib/python3.6/site-packages/django/urls/__init__.py'>' 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.
我最近从 Django 1.8 更新到 2.0,所以我认为这就是错误发生的原因。我认为 urls.py 会导致这个错误,所以我像这样重写了它
from django.urls import include, path
app_name = 'App'
urlpatterns = [
path('admin/', admin.site.urls),
path('app/', include('app.urls')),
] +static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)
但同样的错误也会发生。我真的不明白为什么会发生这个错误。我应该如何解决这个问题?我的代码有什么问题?
【问题讨论】: