mirror of
https://github.com/django/django.git
synced 2024-12-01 15:42:04 +01:00
Fixed #8069 -- Corrected the inconsistent case with BaseInlineFormset. It has been renamed to BaseInlineFormSet. Backward incompatible for anyone who used BaseInlineFormset directly.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8243 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
32d5c39016
commit
c49eac7d4f
@ -1,7 +1,7 @@
|
||||
from django import forms, template
|
||||
from django.forms.formsets import all_valid
|
||||
from django.forms.models import modelform_factory, inlineformset_factory
|
||||
from django.forms.models import BaseInlineFormset
|
||||
from django.forms.models import BaseInlineFormSet
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.contrib.admin import widgets
|
||||
from django.contrib.admin.util import quote, unquote, get_deleted_objects
|
||||
@ -735,7 +735,7 @@ class InlineModelAdmin(BaseModelAdmin):
|
||||
"""
|
||||
model = None
|
||||
fk_name = None
|
||||
formset = BaseInlineFormset
|
||||
formset = BaseInlineFormSet
|
||||
extra = 3
|
||||
max_num = 0
|
||||
template = None
|
||||
|
@ -400,7 +400,7 @@ def modelformset_factory(model, form=ModelForm, formfield_callback=lambda f: f.f
|
||||
|
||||
# InlineFormSets #############################################################
|
||||
|
||||
class BaseInlineFormset(BaseModelFormSet):
|
||||
class BaseInlineFormSet(BaseModelFormSet):
|
||||
"""A formset for child objects related to a parent."""
|
||||
def __init__(self, data=None, files=None, instance=None,
|
||||
save_as_new=False, prefix=None):
|
||||
@ -409,13 +409,13 @@ class BaseInlineFormset(BaseModelFormSet):
|
||||
self.save_as_new = save_as_new
|
||||
# is there a better way to get the object descriptor?
|
||||
self.rel_name = RelatedObject(self.fk.rel.to, self.model, self.fk).get_accessor_name()
|
||||
super(BaseInlineFormset, self).__init__(data, files, prefix=prefix or self.rel_name)
|
||||
super(BaseInlineFormSet, self).__init__(data, files, prefix=prefix or self.rel_name)
|
||||
|
||||
def _construct_forms(self):
|
||||
if self.save_as_new:
|
||||
self._total_form_count = self._initial_form_count
|
||||
self._initial_form_count = 0
|
||||
super(BaseInlineFormset, self)._construct_forms()
|
||||
super(BaseInlineFormSet, self)._construct_forms()
|
||||
|
||||
def get_queryset(self):
|
||||
"""
|
||||
@ -466,12 +466,12 @@ def _get_foreign_key(parent_model, model, fk_name=None):
|
||||
|
||||
|
||||
def inlineformset_factory(parent_model, model, form=ModelForm,
|
||||
formset=BaseInlineFormset, fk_name=None,
|
||||
formset=BaseInlineFormSet, fk_name=None,
|
||||
fields=None, exclude=None,
|
||||
extra=3, can_order=False, can_delete=True, max_num=0,
|
||||
formfield_callback=lambda f: f.formfield()):
|
||||
"""
|
||||
Returns an ``InlineFormset`` for the given kwargs.
|
||||
Returns an ``InlineFormSet`` for the given kwargs.
|
||||
|
||||
You must provide ``fk_name`` if ``model`` has more than one ``ForeignKey``
|
||||
to ``parent_model``.
|
||||
|
@ -608,7 +608,7 @@ more than one foreign key to the same parent model.
|
||||
``formset``
|
||||
~~~~~~~~~~~
|
||||
|
||||
This defaults to ``BaseInlineFormset``. Using your own formset can give you
|
||||
This defaults to ``BaseInlineFormSet``. Using your own formset can give you
|
||||
many possibilities of customization. Inlines are built around
|
||||
`model formsets`_.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user