【发布时间】:2021-03-22 05:30:19
【问题描述】:
我需要一些帮助来解决这个问题。我想我正在执行 django 文档 (https://docs.djangoproject.com/en/3.1/topics/class-based-views/generic-display/) 的建议,但我不断收到此错误:get() got multiple values for argument 'self'
textbook_list.html
<a href="{% url 'lesson_list' textbook.pk %}">
<button type="button" class="btn btn-info">More Info</button>
</a>
urls.py
urlpatterns = [path('grade/<int:pk>/', TextbookLessonList.as_view(), name='lesson_list')]
views.py
class TextbookLessonList(ListView):
template_name = 'textbook_lesson_list.html'
def get_queryset(self):
self.textbook = get_object_or_404(Textbook, self=self.kwargs['pk']) #This is the offending line
return TextbookLesson.objects.filter(textbook.pk==self.textbook)
【问题讨论】:
标签: django django-views django-templates django-generic-views