Я изучаю Django с djbook и до сих пор создал мое приложение для опросов. Он работает нормально, но когда я добавил файл журнала, в нем есть сообщение об ошибке:
Exception while resolving variable 'name' in template 'unknown'.
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/usr/lib/python3.8/site-packages/django/core/handlers/base.py", line 100, in _get_response
resolver_match = resolver.resolve(request.path_info)
File "/usr/lib/python3.8/site-packages/django/urls/resolvers.py", line 567, in resolve
raise Resolver404({'tried': tried, 'path': new_path})
django.urls.exceptions.Resolver404: {'tried': [[<URLResolver <URLPattern list> (admin:admin) 'admin/'>], [<URLResolver <module 'polls.urls' from '/home/DeadMoroz/mysite/polls/urls.py'> (polls:polls) 'polls/'>]], 'path': ''}
...
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/django/template/base.py", line 848, in _resolve_lookup
raise VariableDoesNotExist("Failed lookup for key "
django.template.base.VariableDoesNotExist: Failed lookup for key [name] in <URLResolver <module 'polls.urls' from '/home/DeadMoroz/mysite/polls/urls.py'> (polls:polls) 'polls/'>
Not Found: /
(0.011) SELECT "polls_question"."id", "polls_question"."question_text", "polls_question"."pub_date", "polls_question"."author" FROM "polls_question" WHERE "polls_question"."pub_date" <= '2020-04-28 04:40:16.152659' ORDER BY "polls_question"."pub_date" DESC LIMIT 5; args=('2020-04-28 04:40:16.152659',)
Мой 'polls / urls.py' файл выглядит так же, как в Django Книга:
from django.urls import path
from . import views
app_name = 'polls'
urlpatterns = [
path('', views.IndexView.as_view(), name='index'),
path('<int:pk>/', views.DetailView.as_view(), name='detail'),
path('<int:pk>/results/', views.ResultsView.as_view(), name='results'),
path('<int:question_id>/vote/', views.vote, name='vote'),
]
Вот моя файловая структура проекта:
polls/
---logs/
------debug.log
---migrations/
---static/
------polls/
---------images/
------------background.gif
------style.css
---templates/
------admin/
---------base_site.html
------polls/
---------detail.html
---------index.html
---------results.html
---__init.py__
---admin.py
---apps.py
---models.py
---tests.py
---urls.py
---views.py
Я очень новичок в Django, любая помощь будет оценена!