找不到:django.core.exceptions.ImproperlyConfigured的解决方案:所包含的URLconf似乎没有任何模式

时间:2019-02-24 16:45:17

标签: django

需要帮助以了解我在做什么错: 与Django框架有关, 我正在尝试映射基本URL进行查看:这是应用程序的url.py:https://www.screencast.com/t/DODOUYBhYK 这是主项目的urls.py: https://www.screencast.com/t/NjjFQ9HQ 当我使用python manage.py makemigrations learninglogs(学习日志是应用程序)时,出现了此错误

(venv) C:\Users\Dell\PycharmProjects\Learning_Log>python manage.py makemigrations learninglogs
Traceback (most recent call last):
File "C:\Users\Dell\PycharmProjects\Learning_Log\venv\lib\site-packages\django\urls\resolvers.py", line 535, 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 "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\Dell\PycharmProjects\Learning_Log\venv\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "C:\Users\Dell\PycharmProjects\Learning_Log\venv\lib\site-packages\django\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\Dell\PycharmProjects\Learning_Log\venv\lib\site-packages\django\core\management\base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\Dell\PycharmProjects\Learning_Log\venv\lib\site-packages\django\core\management\base.py", line 350, in execute
self.check()
File "C:\Users\Dell\PycharmProjects\Learning_Log\venv\lib\site-packages\django\core\management\base.py", line 379, in check
include_deployment_checks=include_deployment_checks,
File "C:\Users\Dell\PycharmProjects\Learning_Log\venv\lib\site-packages\django\core\management\base.py", line 366, in _run_checks
return checks.run_checks(**kwargs)
File "C:\Users\Dell\PycharmProjects\Learning_Log\venv\lib\site-packages\django\core\checks\registry.py", line 71, in run_checks
new_errors = check(app_configs=app_configs)
File "C:\Users\Dell\PycharmProjects\Learning_Log\venv\lib\site-packages\django\core\checks\urls.py", line 40, in check_url_namespaces_unique
all_namespaces = _load_all_namespaces(resolver)
File "C:\Users\Dell\PycharmProjects\Learning_Log\venv\lib\site-packages\django\core\checks\urls.py", line 67, in _load_all_namespaces
namespaces.extend(_load_all_namespaces(pattern, current))
File "C:\Users\Dell\PycharmProjects\Learning_Log\venv\lib\site-packages\django\core\checks\urls.py", line 57, in _load_all_namespaces
url_patterns = getattr(resolver, 'url_patterns', [])
File "C:\Users\Dell\PycharmProjects\Learning_Log\venv\lib\site-packages\django\utils\functional.py", line 37, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\Dell\PycharmProjects\Learning_Log\venv\lib\site-packages\django\urls\resolvers.py", line 542, in url_patterns
raise ImproperlyConfigured(msg.format(name=self.urlconf_name))
django.core.exceptions.ImproperlyConfigured: The included URLconf '<module 'learninglogs.urls' from 'C:\\Users\\Dell\\PycharmProjects\\Learning_Log\\learninglogs\\urls.py'>' does not a
ppear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import.

当我从url_patterns删除下划线时,出现此错误:

Traceback (most recent call last):
  File "C:/Users/Dell/PycharmProjects/Learning_Log/learninglog/urls.py", line 22, in <module>
    path('admin/', admin.site.urls),
  File "C:\Users\Dell\PycharmProjects\Learning_Log\venv\lib\site-packages\django\utils\functional.py", line 213, in inner
    self._setup()
  File "C:\Users\Dell\PycharmProjects\Learning_Log\venv\lib\site-packages\django\contrib\admin\sites.py", line 526, in _setup
    AdminSiteClass = import_string(apps.get_app_config('admin').default_site)
  File "C:\Users\Dell\PycharmProjects\Learning_Log\venv\lib\site-packages\django\apps\registry.py", line 150, in get_app_config
    self.check_apps_ready()
  File "C:\Users\Dell\PycharmProjects\Learning_Log\venv\lib\site-packages\django\apps\registry.py", line 131, in check_apps_ready
    settings.INSTALLED_APPS
  File "C:\Users\Dell\PycharmProjects\Learning_Log\venv\lib\site-packages\django\conf\__init__.py", line 57, in __getattr__
    self._setup(name)
  File "C:\Users\Dell\PycharmProjects\Learning_Log\venv\lib\site-packages\django\conf\__init__.py", line 42, in _setup
    % (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

Process finished with exit code 1

0 个答案:

没有答案