summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorChris Cogdon <chris.cogdon@dtexsystems.com>2015-12-30 13:22:58 -0800
committerTim Graham <timograham@gmail.com>2015-12-30 17:30:37 -0500
commit8202ce45a5ae5dac2c6fdf94bf3554180bbdd7b7 (patch)
tree44499352a12216650399de6c6d3d6b5628ea8e68 /django
parent4d9b98616f2d8b98946fdc752cc40f4283baf105 (diff)
[1.9.x] Fixed #26018 -- Prevented unecessary get_form() call in FormMixin.get_context_data().
Changed "dict.setdefault" to "if x in dict" pattern so that get_form() would not be called unnecessarily, specifically in the case where FormMixin.form_invalid() calls get_context_data() with the current form. Backport of e429c5186ceed81c4627165518e0c70c58e69595 from master
Diffstat (limited to 'django')
-rw-r--r--django/views/generic/edit.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/django/views/generic/edit.py b/django/views/generic/edit.py
index 4ebf06a497..624883374d 100644
--- a/django/views/generic/edit.py
+++ b/django/views/generic/edit.py
@@ -118,7 +118,8 @@ class FormMixin(six.with_metaclass(FormMixinBase, ContextMixin)):
"""
Insert the form into the context dict.
"""
- kwargs.setdefault('form', self.get_form())
+ if 'form' not in kwargs:
+ kwargs['form'] = self.get_form()
return super(FormMixin, self).get_context_data(**kwargs)