#30699: Remove `PublisherDetail.get_context_data()` from documentation
------------------------------------------------+------------------------
Reporter: Davit Gachechiladze | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 2.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
The following code snippet is from
[https://docs.djangoproject.com/en/2.2/topics/class-based-views/mixins/]
{{{#!python
from django.views.generic import ListView
from django.views.generic.detail import SingleObjectMixin
from books.models import Publisher
class PublisherDetail(SingleObjectMixin, ListView):
paginate_by = 2
template_name = "books/publisher_detail.html"
def get(self, request, *args, **kwargs):
self.object = self.get_object(queryset=Publisher.objects.all())
return super().get(request, *args, **kwargs)
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['publisher'] = self.object
return context
def get_queryset(self):
return self.object.book_set.all()
}}}
`PublisherDetail.get_context_data(self, **kwargs)` is not neccessary here
at all, isn't it ? `SingleObjectMixin.get_context_data(self, **kwargs)` is
responsible to add `publisher` key in `context` dict, which is called from
`BaseListView.get(self, request, *args, **kwargs)`.
--
Ticket URL: <https://code.djangoproject.com/ticket/30699>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/052.127612b2cd48eb0b7ce33257d4989b79%40djangoproject.com.