diff options
| author | Gilberto Gonçalves <lursty@gmail.com> | 2013-06-22 12:12:43 +0100 |
|---|---|---|
| committer | Gilberto Gonçalves <lursty@gmail.com> | 2013-06-22 12:12:43 +0100 |
| commit | ef37b23050637da643b47b1ee744702d4d603f4c (patch) | |
| tree | 74e22031ce1798084cd59e06fd8ff402ddbcb54c /django | |
| parent | ef79582e8630cb3c119caed52130c9671188addd (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.py | 13 |
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, |
