mirror of
https://github.com/django/django.git
synced 2025-11-17 02:24:22 +00:00
Fixed #24643 -- Added get_context_data() method to FormMixin
This commit is contained in:
parent
a37dcfd0a3
commit
8a1824d465
5 changed files with 40 additions and 8 deletions
|
|
@ -112,7 +112,14 @@ class FormMixin(six.with_metaclass(FormMixinBase, ContextMixin)):
|
|||
If the form is invalid, re-render the context data with the
|
||||
data-filled form and errors.
|
||||
"""
|
||||
return self.render_to_response(self.get_context_data(form=form))
|
||||
return self.render_to_response(self.get_context_data())
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
"""
|
||||
Insert the form into the context dict.
|
||||
"""
|
||||
kwargs.setdefault('form', self.get_form())
|
||||
return super(FormMixin, self).get_context_data(**kwargs)
|
||||
|
||||
|
||||
class ModelFormMixin(FormMixin, SingleObjectMixin):
|
||||
|
|
@ -202,8 +209,7 @@ class ProcessFormView(View):
|
|||
"""
|
||||
Handles GET requests and instantiates a blank version of the form.
|
||||
"""
|
||||
form = self.get_form()
|
||||
return self.render_to_response(self.get_context_data(form=form))
|
||||
return self.render_to_response(self.get_context_data())
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue