class PublisherDetail(DetailView):
model = Publisher
def get_context_data(self, **kwargs):
# Call the base implementation first to get a context
context = super().get_context_data(**kwargs)
# Add in a QuerySet of all the books
context['book_list'] = Book.objects.all()
return context
Asked
Active
Viewed 29 times
-2
-
https://docs.python.org/3/library/functions.html#super – iklinac Aug 30 '20 at 19:46
-
2Does this answer your question? [What does 'super' do in Python?](https://stackoverflow.com/questions/222877/what-does-super-do-in-python) – jonrsharpe Aug 30 '20 at 19:47
1 Answers
0
According to the basic Python inheritance rules, super().get_context_data(...)
would be DetailView.get_context_data()
, but since it's not defined, it's inherited down from SingleObjectMixin
.

AKX
- 152,115
- 15
- 115
- 172