django makemigrations 错误:TypeError: 'module' object is not iterable

错误描述:

在执行 python manage.py makemigrations 命令产生迁移文件时,抛出了 TypeError: 'module' object is not iterable 异常,具体信息如下:

TypeError: 'module' object is not iterable

Traceback (most recent call last):
  File "C:\Users\Emanuele\Desktop\Django_Env\lib\site-packages\django\urls\resolvers.py", line 591, in url_patterns
    iter(patterns)
TypeError: 'module' object is not iterable

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    main()
  File "manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "C:\Users\Emanuele\Desktop\Django_Env\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "C:\Users\Emanuele\Desktop\Django_Env\lib\site-packages\django\core\management\__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\Emanuele\Desktop\Django_Env\lib\site-packages\django\core\management\base.py", line 330, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\Emanuele\Desktop\Django_Env\lib\site-packages\django\core\management\base.py", line 368, in execute
    self.check()
  File "C:\Users\Emanuele\Desktop\Django_Env\lib\site-packages\django\core\management\base.py", line 396, in check
    databases=databases,
  File "C:\Users\Emanuele\Desktop\Django_Env\lib\site-packages\django\core\checks\registry.py", line 70, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "C:\Users\Emanuele\Desktop\Django_Env\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
    return check_resolver(resolver)
  File "C:\Users\Emanuele\Desktop\Django_Env\lib\site-packages\django\core\checks\urls.py", line 23, in check_reso`enter code here`lver
    return check_method()
  File "C:\Users\Emanuele\Desktop\Django_Env\lib\site-packages\django\urls\resolvers.py", line 409, in check
    messages.extend(check_resolver(pattern))
  File "C:\Users\Emanuele\Desktop\Django_Env\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
    return check_method()
  File "C:\Users\Emanuele\Desktop\Django_Env\lib\site-packages\django\urls\resolvers.py", line 408, in check
    for pattern in self.url_patterns:
  File "C:\Users\Emanuele\Desktop\Django_Env\lib\site-packages\django\utils\functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\Emanuele\Desktop\Django_Env\lib\site-packages\django\urls\resolvers.py", line 598, in url_patterns
    raise ImproperlyConfigured(msg.format(name=self.urlconf_name)) from e
django.core.exceptions.ImproperlyConfigured: The included URLconf '<module 'flights.urls' from 'C:\\Users\\Emanuele\\Desktop\\Airline\\flights\\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.

我的解决方法:

我在总路由中有用include分发应用子路由,因此要在子应用下创建 urls.py 文件,并且里面要有urlpatterns

# 子应用/urls.py

urlpatterns = [
]

如果对你有用,请给我一个赞吧 (0。0)

上一篇:volatility内存取证问题,命令总结,解题思路汇总


下一篇:django删除数据库表,重新makemigrations与migrate数据库不能再生成表的问题