Fix TypeError when ``base_form`` was not defined.
parent
b622d6f6a1
commit
e0446bd76c
|
|
@ -1,6 +1,12 @@
|
||||||
Changelog
|
Changelog
|
||||||
==========
|
==========
|
||||||
|
|
||||||
|
Version 0.5.3 (2013-09-17)
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
* Fix TypeError when ``base_form`` was not defined.
|
||||||
|
|
||||||
|
|
||||||
Version 0.5.2 (2013-09-05)
|
Version 0.5.2 (2013-09-05)
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -400,8 +400,7 @@ class PolymorphicChildModelAdmin(admin.ModelAdmin):
|
||||||
#
|
#
|
||||||
# Instead, pass the form unchecked here, because the standard ModelForm will just work.
|
# Instead, pass the form unchecked here, because the standard ModelForm will just work.
|
||||||
# If the derived class sets the model explicitly, respect that setting.
|
# If the derived class sets the model explicitly, respect that setting.
|
||||||
if not self.form:
|
kwargs.setdefault('form', self.base_form or self.form)
|
||||||
kwargs['form'] = self.base_form
|
|
||||||
return super(PolymorphicChildModelAdmin, self).get_form(request, obj, **kwargs)
|
return super(PolymorphicChildModelAdmin, self).get_form(request, obj, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -479,11 +478,6 @@ class PolymorphicChildModelAdmin(admin.ModelAdmin):
|
||||||
return self.base_fieldsets
|
return self.base_fieldsets
|
||||||
|
|
||||||
|
|
||||||
def get_form(self, request, obj=None, **kwargs):
|
|
||||||
kwargs.setdefault('form', self.base_form)
|
|
||||||
return super(PolymorphicChildModelAdmin, self).get_form(request, obj, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
def get_subclass_fields(self, request, obj=None):
|
def get_subclass_fields(self, request, obj=None):
|
||||||
# Find out how many fields would really be on the form,
|
# Find out how many fields would really be on the form,
|
||||||
# if it weren't restricted by declared fields.
|
# if it weren't restricted by declared fields.
|
||||||
|
|
@ -492,7 +486,7 @@ class PolymorphicChildModelAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
# By not declaring the fields/form in the base class,
|
# By not declaring the fields/form in the base class,
|
||||||
# get_form() will populate the form with all available fields.
|
# get_form() will populate the form with all available fields.
|
||||||
form = self.get_form(request, obj, exclude=exclude, form=self.base_form)
|
form = self.get_form(request, obj, exclude=exclude)
|
||||||
subclass_fields = list(six.iterkeys(form.base_fields)) + list(self.get_readonly_fields(request, obj))
|
subclass_fields = list(six.iterkeys(form.base_fields)) + list(self.get_readonly_fields(request, obj))
|
||||||
|
|
||||||
# Find which fields are not part of the common fields.
|
# Find which fields are not part of the common fields.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue