Django.core.exeptions.ImproperlyConfigured:所包含的URLconf中似乎没有任何模式

时间:2019-12-15 15:15:45

标签: python django django-urls

from django.contrib import admin
from django.urls import path, include
import Echo.urls
import users.urls
#this is the urls
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('Echo.urls', namespace='Echo')),
path('users/', include('users.urls', namespace='users'))
]
users/urls.py
"""Defines URL patterns for users"""

from django.conf.urls import url
from django.contrib.auth.views import login#importing default login view
from . import views

app_name = 'users'
urlpatterns = [
# Login page
url(r'^login/$', login, {'template_name': 'users/login.html'},
name='login'),
# Logout page
url(r'^logout/$', views.logout_view, name='logout'),
# Registration page
url(r'^register/$', views.register, name='register')

]
Echo/urls.py
#Defines Urls for Echo

from django.urls import path
from . import views

app_name = 'Echo'
urlpatterns = [
path('', views.index, name='index'),
path('companies/', views.business, name='companies'),
path('company/<int:pk>', 
views.BusinessDetail.as_view(),name='BusinessDetail')

]

error message

Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Python35\lib\site-packages\django\urls\resolvers.py", line 581, in 
url_patterns
iter(patterns)
TypeError: 'module' object is not iterable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Python35\lib\threading.py", line 914, in _bootstrap_inner
self.run()
File "C:\Python35\lib\threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "C:\Python35\lib\site-packages\django\utils\autoreload.py", line 54, in 
wrapper
fn(*args, **kwargs)
File "C:\Python35\lib\site- 
packages\django\core\management\commands\runserver.py", line 117, in 
inner_run
self.check(display_num_errors=True)
File "C:\Python35\lib\site-packages\django\core\management\base.py", line 
390, in check
include_deployment_checks=include_deployment_checks,
File "C:\Python35\lib\site-packages\django\core\management\base.py", line 
377, in _run_checks
return checks.run_checks(**kwargs)
File "C:\Python35\lib\site-packages\django\core\checks\registry.py", line 
72, in run_checks
new_errors = check(app_configs=app_configs)
File "C:\Python35\lib\site-packages\django\core\checks\urls.py", line 13, in 
check_url_config
return check_resolver(resolver)
File "C:\Python35\lib\site-packages\django\core\checks\urls.py", line 23, in 
check_resolver
return check_method()
File "C:\Python35\lib\site-packages\django\urls\resolvers.py", line 398, in 
check
for pattern in self.url_patterns:
File "C:\Python35\lib\site-packages\django\utils\functional.py", line 80, in 
__get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Python35\lib\site-packages\django\urls\resolvers.py", line 588, in 
url_patterns
raise ImproperlyConfigured(msg.format(name=self.urlconf_name))
django.core.exceptions.ImproperlyConfigured: The included URLconf 
'mysite.urls' 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 我添加了所有网址文件 我还添加了错误消息 我检查了所有语法,似乎没有什么错 所有建议表示赞赏 python更新 点更新 引导程序已安装 图案缺失错误 代码包含有关错误的信息 图案缺失错误 代码包含有关错误的信息 图案缺失错误 代码包含有关错误的信息 图案缺失错误 代码包含有关错误的信息 图案缺失错误 代码包含有关错误的信息

1 个答案:

答案 0 :(得分:0)

回溯的最后一部分是这里的问题:您有循环导入

只需将您的urls.py更改为:

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


urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('Echo.urls', namespace='Echo')),
    path('users/', include('users.urls', namespace='users'))
]

(删除Echo.urlsusers.urls导入)