django - 如何使用 url 修复 django 'django.core.exceptions.ImproperlyConfigured' 的错误?

标签 django python-3.x

from django.contrib import admin
from django.urls import path, include


urlpatterns = [
    path('admin/', admin.site.urls),
    path('polls/', include('polls.urls')),
]

将 url 添加到 url.py 时出现错误。

当我在终端中运行代码时:'python manage.py runserver';然后在终端显示以下错误-

django.core.exceptions.ImproperlyConfigured: The included URLconf 
'<module 'polls.urls' from 


'C:\\Users\\Administrator\\PycharmProjects\\website2\\mysite\\polls\\urls.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 中非常罕见,仅在 flask 中很常见。

此错误是由在 django 应用中创建的 urls.py 中的 'urlpatterns' 拼写错误引起的。

这也可能是由于没有在 urls.py 文件中的 urlpatterns 中定义它

该错误可能是由上述原因之一引起的。

就这么简单

关于django - 如何使用 url 修复 django 'django.core.exceptions.ImproperlyConfigured' 的错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57743868/

相关文章:

python - process_template_response 在 Django 中不会被调用

python - Unicode编码错误: 'charmap' codec can't encode character '\U0001f937' in position 0: character maps to <undefined>

python - 在 sklearn.preprocessing 模块中,我得到 ValueError : Found array with 0 feature(s)

python - 将嵌套的 JSON 数据传递为 Html 表格式

python - 包含列表列表的文本文件的串联?

Django注册SMTPServerDisconnected错误

django - 何时在 Django 1.5 中使用自定义用户模型

python - Django:没有名为应用程序的模块

python - 我应该也固定开发要求,还是只固定安装要求?

django - 我的 Ubuntu Apache Conf 文件有问题。 (禁止您无权访问此服务器上的/。)