Fixed #9171 -- Fixed a few places where we were assuming lists instead of
generic sequences in ModelForm structures. Patch from mrmachine. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9086 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
edabc4aca1
commit
6c7cf34d69
|
@ -266,7 +266,7 @@ class ModelAdmin(BaseModelAdmin):
|
||||||
if self.exclude is None:
|
if self.exclude is None:
|
||||||
exclude = []
|
exclude = []
|
||||||
else:
|
else:
|
||||||
exclude = self.exclude
|
exclude = list(self.exclude)
|
||||||
defaults = {
|
defaults = {
|
||||||
"form": self.form,
|
"form": self.form,
|
||||||
"fields": fields,
|
"fields": fields,
|
||||||
|
@ -780,7 +780,7 @@ class InlineModelAdmin(BaseModelAdmin):
|
||||||
if self.exclude is None:
|
if self.exclude is None:
|
||||||
exclude = []
|
exclude = []
|
||||||
else:
|
else:
|
||||||
exclude = self.exclude
|
exclude = list(self.exclude)
|
||||||
defaults = {
|
defaults = {
|
||||||
"form": self.form,
|
"form": self.form,
|
||||||
"formset": self.formset,
|
"formset": self.formset,
|
||||||
|
|
|
@ -528,6 +528,7 @@ def inlineformset_factory(parent_model, model, form=ModelForm,
|
||||||
if fk.unique:
|
if fk.unique:
|
||||||
max_num = 1
|
max_num = 1
|
||||||
if exclude is not None:
|
if exclude is not None:
|
||||||
|
exclude = list(exclude)
|
||||||
exclude.append(fk.name)
|
exclude.append(fk.name)
|
||||||
else:
|
else:
|
||||||
exclude = [fk.name]
|
exclude = [fk.name]
|
||||||
|
|
|
@ -51,5 +51,7 @@ Traceback (most recent call last):
|
||||||
Exception: <class 'regressiontests.inline_formsets.models.Child'> has no field named 'test'
|
Exception: <class 'regressiontests.inline_formsets.models.Child'> has no field named 'test'
|
||||||
|
|
||||||
|
|
||||||
|
# Regression test for #9171.
|
||||||
|
>>> ifs = inlineformset_factory(Parent, Child, exclude=('school',), fk_name='mother')
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,6 +124,14 @@ displayed because you forgot to add it to fields/fielsets
|
||||||
>>> ma.get_form(request).base_fields.keys()
|
>>> ma.get_form(request).base_fields.keys()
|
||||||
['name', 'sign_date']
|
['name', 'sign_date']
|
||||||
|
|
||||||
|
# You can also pass a tuple to `exclude`.
|
||||||
|
|
||||||
|
>>> class BandAdmin(ModelAdmin):
|
||||||
|
... exclude = ('bio',)
|
||||||
|
>>> ma = BandAdmin(Band, site)
|
||||||
|
>>> ma.get_form(request).base_fields.keys()
|
||||||
|
['name', 'sign_date']
|
||||||
|
|
||||||
# Using `fields` and `exclude`.
|
# Using `fields` and `exclude`.
|
||||||
|
|
||||||
>>> class BandAdmin(ModelAdmin):
|
>>> class BandAdmin(ModelAdmin):
|
||||||
|
|
Loading…
Reference in New Issue