Я пытаюсь перечислить все содержимое в представлениях списка, и если пользователь нажимает на это содержимое в списке, то пользователь показывает подробное представление, и я сделал просмотр списка, но неудачный подробный просмотр получил ошибку.
я получил первую ошибку, было орфографической ошибкой в поле модели, затем я исправляю и мигрирую, затем я получаю эту ошибку.
Traceback (most recent call last):
File "C:\Users\Khan\Miniconda3\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
response = get_response(request)
File "C:\Users\Khan\Miniconda3\lib\site-packages\django\core\handlers\base.py", line 145, in _get_response
response = self.process_exception_by_middleware(e, request)
File "C:\Users\Khan\Miniconda3\lib\site-packages\django\core\handlers\base.py", line 143, in _get_response
response = response.render()
File "C:\Users\Khan\Miniconda3\lib\site-packages\django\template\response.py", line 105, in render
self.content = self.rendered_content
File "C:\Users\Khan\Miniconda3\lib\site-packages\django\template\response.py", line 83, in rendered_content
return template.render(context, self._request)
File "C:\Users\Khan\Miniconda3\lib\site-packages\django\template\backends\django.py", line 61, in render
return self.template.render(context)
File "C:\Users\Khan\Miniconda3\lib\site-packages\django\template\base.py", line 171, in render
return self._render(context)
File "C:\Users\Khan\Miniconda3\lib\site-packages\django\template\base.py", line 163, in _render
return self.nodelist.render(context)
File "C:\Users\Khan\Miniconda3\lib\site-packages\django\template\base.py", line 936, in render
bit = node.render_annotated(context)
File "C:\Users\Khan\Miniconda3\lib\site-packages\django\template\base.py", line 903, in render_annotated
return self.render(context)
File "C:\Users\Khan\Miniconda3\lib\site-packages\django\template\defaulttags.py", line 209, in render
nodelist.append(node.render_annotated(context))
File "C:\Users\Khan\Miniconda3\lib\site-packages\django\template\base.py", line 903, in render_annotated
return self.render(context)
File "C:\Users\Khan\Miniconda3\lib\site-packages\django\template\base.py", line 986, in render
output = self.filter_expression.resolve(context)
File "C:\Users\Khan\Miniconda3\lib\site-packages\django\template\base.py", line 670, in resolve
obj = self.var.resolve(context)
File "C:\Users\Khan\Miniconda3\lib\site-packages\django\template\base.py", line 795, in resolve
value = self._resolve_lookup(context)
File "C:\Users\Khan\Miniconda3\lib\site-packages\django\template\base.py", line 857, in _resolve_lookup
current = current()
File "C:\Users\Khan\Desktop\YouTube\videoservice\courses\models.py", line 37, in get_absolute_url
'lesson-slug': self.slug
File "C:\Users\Khan\Miniconda3\lib\site-packages\django\urls\base.py", line 87, in reverse
return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
File "C:\Users\Khan\Miniconda3\lib\site-packages\django\urls\resolvers.py", line 677, in _reverse_with_prefix
raise NoReverseMatch(msg)
Exception Type: NoReverseMatch at /django-101
Exception Value: Reverse for 'lesson-detail' with keyword arguments '{'course_slug': 'django-101', 'lesson-slug': 'first'}' not found. 1 pattern(s) tried: ['(?P<course_slug>[^/]+)/(?P<lesson_slug>[^/]+)$']**
urls.py
from django.urls import path
from .views import CourseListView, CourseDetailView, LessonDetailView
app_name = 'courses'
urlpatterns = [
path('', CourseListView.as_view(), name='list'),
path('<slug>', CourseDetailView.as_view(), name='detail'),
path('<course_slug>/<lesson_slug>', LessonDetailView.as_view(), name='lesson-detail')
]
course_detail. html
<!DOCTYPE html>
<html>
<head>
<title>Detail view</title>
</head>
<body>
{{ object.title }}
{% for lesson in object.lessons %}
<a href="{{ lesson.get_absolute_url }}">{{ lesson.title }}</a>
{% endfor %}
</body>
</html>