summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorGilberto Gonçalves <lursty@gmail.com>2013-06-22 12:12:43 +0100
committerGilberto Gonçalves <lursty@gmail.com>2013-06-22 12:12:43 +0100
commitef37b23050637da643b47b1ee744702d4d603f4c (patch)
tree74e22031ce1798084cd59e06fd8ff402ddbcb54c /django
parentef79582e8630cb3c119caed52130c9671188addd (diff)
Fixed #18872 -- Added prefix to FormMixin
Thanks @ibustama for the initial patch and dragonsnaker for opening the report.
Diffstat (limited to 'django')
-rw-r--r--django/views/generic/edit.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/django/views/generic/edit.py b/django/views/generic/edit.py
index b31d7a218f..193071efc5 100644
--- a/django/views/generic/edit.py
+++ b/django/views/generic/edit.py
@@ -17,6 +17,7 @@ class FormMixin(ContextMixin):
initial = {}
form_class = None
success_url = None
+ prefix = None
def get_initial(self):
"""
@@ -24,6 +25,12 @@ class FormMixin(ContextMixin):
"""
return self.initial.copy()
+ def get_prefix(self):
+ """
+ Returns the prefix to use for forms on this view
+ """
+ return self.prefix
+
def get_form_class(self):
"""
Returns the form class to use in this view
@@ -40,7 +47,11 @@ class FormMixin(ContextMixin):
"""
Returns the keyword arguments for instantiating the form.
"""
- kwargs = {'initial': self.get_initial()}
+ kwargs = {
+ 'initial': self.get_initial(),
+ 'prefix': self.get_prefix(),
+ }
+
if self.request.method in ('POST', 'PUT'):
kwargs.update({
'data': self.request.POST,