如果您在文件中看到有效模式,则问题可能是由循环导入引起的不是错字,而是由循环导入引起的

如何解决如果您在文件中看到有效模式,则问题可能是由循环导入引起的不是错字,而是由循环导入引起的

这很不寻常。代码运行良好,但突然出现此错误

     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 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?