【问题标题】:Exception: 'module' object is not iterable例外:“模块”对象不可迭代
【发布时间】:2021-05-28 22:42:37
【问题描述】:

当我从Github project 运行代码时,我收到此错误:

Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/django/urls/resolvers.py", line 600, in url_patterns
    iter(patterns)
TypeError: 'module' object is not iterable

上述异常是以下异常的直接原因:

Traceback (most recent call last):
  File "/data/data/com.termux/files/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner
    self.run()
  File "/data/data/com.termux/files/usr/lib/python3.9/threading.py", line 892, in run
    self._target(*self._args, **self._kwargs)
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/django/utils/autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 118, in inner_run
    self.check(display_num_errors=True)
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/django/core/management/base.py", line 419, in check
    all_issues = checks.run_checks(
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/django/core/checks/registry.py", line 76, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/django/core/checks/urls.py", line 13, in check_url_config
    return check_resolver(resolver)
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/django/core/checks/urls.py", line 23, in check_resolver
    return check_method()
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/django/urls/resolvers.py", line 413, in check
    messages.extend(check_resolver(pattern))
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/django/core/checks/urls.py", line 23, in check_resolver
    return check_method()
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/django/urls/resolvers.py", line 412, in check
    for pattern in self.url_patterns:
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/django/urls/resolvers.py", line 607, in url_patterns
    raise ImproperlyConfigured(msg.format(name=self.urlconf_name)) from e
django.core.exceptions.ImproperlyConfigured: The included URLconf '<module 'blog.urls' from '/storage/emulated/0/application/blog/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.

【问题讨论】:

  • 能否请包含您的 urls.py (blog.urls)。这可能是由一个简单的错字引起的。希望。手指交叉????
  • 这是链接github.com/ijawpikin/projectHub 发现很难编辑和添加堆栈代码

标签: python python-3.x django mobile termux


【解决方案1】:

我从您的 github 链接查看了您的 urls.py 文件

您将urlpatterns 对象大写的地方有一个小错字。

from django.urls import path
from .views import blogListView

Urlpatterns = [ path(' ', blogListView.as_view(), name='home'), 
]

urlpatterns 的拼写必须准确才能使路由正常工作。

轻松修复?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-09-09
    • 2015-11-28
    • 1970-01-01
    • 1970-01-01
    • 2019-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多