Задать вопрос
@Wolron

Почему не запускается сервер Django?

62e3358ab4452815532055.jpegПочему не запускается сервер Django?
Вчера один раз запустил.
Сегодня не запускается.
команда : python manage.py runserver

(venv) c:\python\django-sites\django-premium\testproject>python manage.py runserver

Watching for file changes with StatReloader
Performing system checks...

Exception in thread django-main-thread:
Traceback (most recent call last):
  File "c:\python\django-sites\django-premium\venv\lib\site-packages\django\urls\resolvers.py", line 698, 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 "C:\python\lib\threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "C:\python\lib\threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "c:\python\django-sites\django-premium\venv\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "c:\python\django-sites\django-premium\venv\lib\site-packages\django\core\management\commands\runserver.py", line 134, in inner_run
    self.check(display_num_errors=True)
  File "c:\python\django-sites\django-premium\venv\lib\site-packages\django\core\management\base.py", line 487, in check
    all_issues = checks.run_checks(
  File "c:\python\django-sites\django-premium\venv\lib\site-packages\django\core\checks\registry.py", line 88, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "c:\python\django-sites\django-premium\venv\lib\site-packages\django\core\checks\urls.py", line 14, in check_url_config
    return check_resolver(resolver)
  File "c:\python\django-sites\django-premium\venv\lib\site-packages\django\core\checks\urls.py", line 24, in check_resolver
    return check_method()
  File "c:\python\django-sites\django-premium\venv\lib\site-packages\django\urls\resolvers.py", line 481, in check
    messages.extend(check_resolver(pattern))
  File "c:\python\django-sites\django-premium\venv\lib\site-packages\django\core\checks\urls.py", line 24, in check_resolver
    return check_method()
  File "c:\python\django-sites\django-premium\venv\lib\site-packages\django\urls\resolvers.py", line 480, in check
    for pattern in self.url_patterns:
  File "c:\python\django-sites\django-premium\venv\lib\site-packages\django\utils\functional.py", line 49, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "c:\python\django-sites\django-premium\venv\lib\site-packages\django\urls\resolvers.py", line 706, in url_patterns
    raise ImproperlyConfigured(msg.format(name=self.urlconf_name)) from e
django.core.exceptions.ImproperlyConfigured: The included URLconf '<module 'testapp.urls' from 'c:\\python\\django-sites\\django-premium\\testproject\\testapp\\urls.py'>' does not appear to have any patterns in it. If you see the 'urlpatterns' variable with valid patterns in the file then the issue is probably caused by a circular import.

(venv) c:\python\django-sites\django-premium\testproject>python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

Exception in thread django-main-thread:
Traceback (most recent call last):
  File "c:\python\django-sites\django-premium\venv\lib\site-packages\django\urls\resolvers.py", line 698, 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 "C:\python\lib\threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "C:\python\lib\threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "c:\python\django-sites\django-premium\venv\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "c:\python\django-sites\django-premium\venv\lib\site-packages\django\core\management\commands\runserver.py", line 134, in inner_run
    self.check(display_num_errors=True)
  File "c:\python\django-sites\django-premium\venv\lib\site-packages\django\core\management\base.py", line 487, in check
    all_issues = checks.run_checks(
  File "c:\python\django-sites\django-premium\venv\lib\site-packages\django\core\checks\registry.py", line 88, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "c:\python\django-sites\django-premium\venv\lib\site-packages\django\core\checks\urls.py", line 14, in check_url_config
    return check_resolver(resolver)
  File "c:\python\django-sites\django-premium\venv\lib\site-packages\django\core\checks\urls.py", line 24, in check_resolver
    return check_method()
  File "c:\python\django-sites\django-premium\venv\lib\site-packages\django\urls\resolvers.py", line 481, in check
    messages.extend(check_resolver(pattern))
  File "c:\python\django-sites\django-premium\venv\lib\site-packages\django\core\checks\urls.py", line 24, in check_resolver
    return check_method()
  File "c:\python\django-sites\django-premium\venv\lib\site-packages\django\urls\resolvers.py", line 480, in check
    for pattern in self.url_patterns:
  File "c:\python\django-sites\django-premium\venv\lib\site-packages\django\utils\functional.py", line 49, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "c:\python\django-sites\django-premium\venv\lib\site-packages\django\urls\resolvers.py", line 706, in url_patterns
    raise ImproperlyConfigured(msg.format(name=self.urlconf_name)) from e
django.core.exceptions.ImproperlyConfigured: The included URLconf '<module 'testapp.urls' from 'c:\\python\\django-sites\\django-premium\\testproject\\testapp\\urls.py'>' does not appear to have any patterns in it. If you see the 'urlpatterns' variable with valid patterns in the file then the issue is probably caused by a circular import.
  • Вопрос задан
  • 232 просмотра
Подписаться 2 Простой 2 комментария
Пригласить эксперта
Ответы на вопрос 2
@Los4inin
Никто так и не решил проблему? Появилось то же самое после в старом проекте, возможно после обновления Питона с 3.8 на 3.11
Ответ написан
Комментировать
DoggieMurr
@DoggieMurr
Python Enthusiast
можно посмотреть файл testapp/urls.py
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы