Fixed #20644 -- Add ModelFormMixin.fields to the CBV flattened index

Thanks to Tim Graham for the report and review.
This commit is contained in:
Baptiste Mispelon 2013-06-23 23:43:09 +02:00
parent cd000dacc7
commit 299983616f
2 changed files with 5 additions and 3 deletions

View File

@ -89,6 +89,7 @@ class ModelFormMixin(FormMixin, SingleObjectMixin):
"""
A mixin that provides a way to show and handle a modelform in a request.
"""
fields = None
def get_form_class(self):
"""
@ -109,13 +110,12 @@ class ModelFormMixin(FormMixin, SingleObjectMixin):
# from that
model = self.get_queryset().model
fields = getattr(self, 'fields', None)
if fields is None:
if self.fields is None:
warnings.warn("Using ModelFormMixin (base class of %s) without "
"the 'fields' attribute is deprecated." % self.__class__.__name__,
PendingDeprecationWarning)
return model_forms.modelform_factory(model, fields=fields)
return model_forms.modelform_factory(model, fields=self.fields)
def get_form_kwargs(self):
"""

View File

@ -177,6 +177,7 @@ CreateView
* :attr:`~django.views.generic.base.TemplateResponseMixin.content_type`
* :attr:`~django.views.generic.detail.SingleObjectMixin.context_object_name` [:meth:`~django.views.generic.detail.SingleObjectMixin.get_context_object_name`]
* :attr:`~django.views.generic.edit.ModelFormMixin.fields`
* :attr:`~django.views.generic.edit.FormMixin.form_class` [:meth:`~django.views.generic.edit.FormMixin.get_form_class`]
* :attr:`~django.views.generic.base.View.http_method_names`
* :attr:`~django.views.generic.edit.FormMixin.initial` [:meth:`~django.views.generic.edit.FormMixin.get_initial`]
@ -216,6 +217,7 @@ UpdateView
* :attr:`~django.views.generic.base.TemplateResponseMixin.content_type`
* :attr:`~django.views.generic.detail.SingleObjectMixin.context_object_name` [:meth:`~django.views.generic.detail.SingleObjectMixin.get_context_object_name`]
* :attr:`~django.views.generic.edit.ModelFormMixin.fields`
* :attr:`~django.views.generic.edit.FormMixin.form_class` [:meth:`~django.views.generic.edit.FormMixin.get_form_class`]
* :attr:`~django.views.generic.base.View.http_method_names`
* :attr:`~django.views.generic.edit.FormMixin.initial` [:meth:`~django.views.generic.edit.FormMixin.get_initial`]