TypeError: объект 'module' не является итерируемым. Django DeleteView

Я пишу приложение Django под названием polls

Я решил поместить Deleteview туда

в polls/views.py я поместил

from django.views.generic.edit import DeleteView
class QuestionDelete(DeleteView):
    model = Question
    success_url = reverse('polls:index')

в polls/urls.py в urlpatterns я добавил строку

path('<int:pk>/deletequestion/‘,views.QuestionDelete.as_view(),name="create_new_choice_question"),

и в templates/polls я создал question_confirm_delete.html

<form method="post">{% csrf_token %}
    <p>Are you sure you want to delete "{{ object }}"?</p>
    {{ form }}
    <input type="submit" value="Confirm">
</form>

До этого все работало нормально

но после выполнения 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 "/Users/myuser/PycharmProjects/mypolls1/venv/lib/python3.11/site-packages/django/urls/resolvers.py", line 740, 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 "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
    self.run()
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 975, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/myuser/PycharmProjects/mypolls1/venv/lib/python3.11/site-packages/django/utils/autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "/Users/myuser/PycharmProjects/mypolls1/venv/lib/python3.11/site-packages/django/core/management/commands/runserver.py", line 133, in inner_run
    self.check(display_num_errors=True)
  File "/Users/myuser/PycharmProjects/mypolls1/venv/lib/python3.11/site-packages/django/core/management/base.py", line 486, in check
    all_issues = checks.run_checks(
                 ^^^^^^^^^^^^^^^^^^
  File "/Users/myuser/PycharmProjects/mypolls1/venv/lib/python3.11/site-packages/django/core/checks/registry.py", line 88, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/myuser/PycharmProjects/mypolls1/venv/lib/python3.11/site-packages/django/core/checks/urls.py", line 14, in check_url_config
    return check_resolver(resolver)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/myuser/PycharmProjects/mypolls1/venv/lib/python3.11/site-packages/django/core/checks/urls.py", line 24, in check_resolver
    return check_method()
           ^^^^^^^^^^^^^^
  File "/Users/myuser/PycharmProjects/mypolls1/venv/lib/python3.11/site-packages/django/urls/resolvers.py", line 519, in check
    for pattern in self.url_patterns:
                   ^^^^^^^^^^^^^^^^^
  File "/Users/myuser/PycharmProjects/mypolls1/venv/lib/python3.11/site-packages/django/utils/functional.py", line 47, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
                                         ^^^^^^^^^^^^^^^^^^^
  File "/Users/myuser/PycharmProjects/mypolls1/venv/lib/python3.11/site-packages/django/urls/resolvers.py", line 748, in url_patterns
    raise ImproperlyConfigured(msg.format(name=self.urlconf_name)) from e
django.core.exceptions.ImproperlyConfigured: The included URLconf 'mysite.urls' 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.

Вернуться на верх