Fixed #30648 -- Removed unnecessary overriding get_context_data() from mixins with CBVs docs.

This commit is contained in:
Davit Gachechiladze 2019-07-18 17:57:25 +04:00 committed by Mariusz Felisiak
parent 230d75f59c
commit 7f612eda80
1 changed files with 1 additions and 8 deletions

View File

@ -461,11 +461,6 @@ Our new ``AuthorDetail`` looks like this::
def get_success_url(self):
return reverse('author-detail', kwargs={'pk': self.object.pk})
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['form'] = self.get_form()
return context
def post(self, request, *args, **kwargs):
if not request.user.is_authenticated:
return HttpResponseForbidden()
@ -483,9 +478,7 @@ Our new ``AuthorDetail`` looks like this::
``get_success_url()`` is just providing somewhere to redirect to,
which gets used in the default implementation of
``form_valid()``. We have to provide our own ``post()`` as
noted earlier, and override ``get_context_data()`` to make the
:class:`~django.forms.Form` available in the context data.
``form_valid()``. We have to provide our own ``post()`` as noted earlier.
A better solution
-----------------