如何解决如果您在文件中看到有效模式,则问题可能是由循环导入引起的不是错字,而是由循环导入引起的
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\HP\Desktop\Ecommerce\env\lib\site-packages\django\urls\resolvers.py",line 589,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:\users\hp\appdata\local\programs\python\python36\lib\threading.py",line 916,in _bootstrap_inner
self.run()
File "c:\users\hp\appdata\local\programs\python\python36\lib\threading.py",line 864,in run
self._target(*self._args,**self._kwargs)
File "C:\Users\HP\Desktop\Ecommerce\env\lib\site-packages\django\utils\autoreload.py",line 53,in wrapper
fn(*args,**kwargs)
File "C:\Users\HP\Desktop\Ecommerce\env\lib\site-packages\django\core\management\commands\runserver.py",line 117,in inner_run
self.check(display_num_errors=True)
File "C:\Users\HP\Desktop\Ecommerce\env\lib\site-packages\django\core\management\base.py",line 395,in check
include_deployment_checks=include_deployment_checks,File "C:\Users\HP\Desktop\Ecommerce\env\lib\site-packages\django\core\management\base.py",line 382,in _run_checks
return checks.run_checks(**kwargs)
File "C:\Users\HP\Desktop\Ecommerce\env\lib\site-packages\django\core\checks\registry.py",line 72,in run_checks
new_errors = check(app_configs=app_configs)
File "C:\Users\HP\Desktop\Ecommerce\env\lib\site-packages\django\core\checks\urls.py",line 40,in check_url_namespaces_unique
all_namespaces = _load_all_namespaces(resolver)
File "C:\Users\HP\Desktop\Ecommerce\env\lib\site-packages\django\core\checks\urls.py",line 57,in _load_all_namespaces
url_patterns = getattr(resolver,'url_patterns',[])
File "C:\Users\HP\Desktop\Ecommerce\env\lib\site-packages\django\utils\functional.py",line 48,in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\HP\Desktop\Ecommerce\env\lib\site-packages\django\urls\resolvers.py",line 596,in url_patterns
raise ImproperlyConfigured(msg.format(name=self.URLconf_name))
django.core.exceptions.ImproperlyConfigured: The included URLconf 'backend.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.
我的 backend.urls
from django.contrib import admin
from django.urls import path,include
urlpatterns = [
path('admin/',admin.site.urls),path('api/',include('base.urls')),]
我的 base.urls :
from django.urls import path
from . import views
urlpatterns = [
path('',views.getRoutes,name='getRoutes'),]
我的基地/views.py
from django.shortcuts import render
from django.http import JsonResponse
from .products import products
# Create your views here.
def getRoutes(request):
routes = [
'/api/products/','/api/products/create/','/api/products/upload','/api/products/<id>/reviews/','/api/products/top/','/api/products/<id>/','/api/products/delete/<id>','/api/products/<update>/<id>/',]
return JsonResponse(routes,safe=False)
我使用 django 已经很长时间了,现在从未见过这个错误,确切的代码运行良好,但是当我在视图中定义第二个 func 时,发生了错误,我删除了该 func 但错误没有发生。我已经尝试了所有答案,请帮忙
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。