do not use deprecated and removed declared_fieldsets attribute in admin

fix_request_path_info
Tadas Dailyda 2017-11-02 15:11:15 +02:00
parent 04b5fb423c
commit 5e150ea85a
2 changed files with 3 additions and 8 deletions

View File

@ -18,10 +18,10 @@ Changes in git
* Added ``PolymorphicTypeInvalid`` exception when database was incorrectly imported. * Added ``PolymorphicTypeInvalid`` exception when database was incorrectly imported.
* Added ``polymorphic.utils.get_base_polymorphic_model()`` to find the base model for types. * Added ``polymorphic.utils.get_base_polymorphic_model()`` to find the base model for types.
* Using ``base_model`` on the polymorphic admins is no longer required, as this can be autodetected. * Using ``base_model`` on the polymorphic admins is no longer required, as this can be autodetected.
* Fixed detection and handling of ``declared_fieldsets`` in the admin.
* Fixed manager errors for swappable models. * Fixed manager errors for swappable models.
* Fixed deleteText of ``|as_script_options`` template filter. * Fixed deleteText of ``|as_script_options`` template filter.
* Improved ``polymorphic.utils.reset_polymorphic_ctype()`` to accept models in random ordering. * Improved ``polymorphic.utils.reset_polymorphic_ctype()`` to accept models in random ordering.
* Fix fieldsets handling in the admin (``declared_fieldsets`` is removed since Django 1.9)
Version 1.3 (2017-08-01) Version 1.3 (2017-08-01)

View File

@ -62,10 +62,6 @@ class PolymorphicChildModelAdmin(admin.ModelAdmin):
# If the derived class sets the model explicitly, respect that setting. # If the derived class sets the model explicitly, respect that setting.
kwargs.setdefault('form', self.base_form or self.form) kwargs.setdefault('form', self.base_form or self.form)
# prevent infinite recursion in django 1.6+
if not getattr(self, 'declared_fieldsets', None):
kwargs.setdefault('fields', None)
return super(PolymorphicChildModelAdmin, self).get_form(request, obj, **kwargs) return super(PolymorphicChildModelAdmin, self).get_form(request, obj, **kwargs)
def get_model_perms(self, request): def get_model_perms(self, request):
@ -186,9 +182,8 @@ class PolymorphicChildModelAdmin(admin.ModelAdmin):
# ---- Extra: improving the form/fieldset default display ---- # ---- Extra: improving the form/fieldset default display ----
def get_fieldsets(self, request, obj=None): def get_fieldsets(self, request, obj=None):
# If subclass declares fieldsets, this is respected # If subclass declares fieldsets or fields, this is respected
if (hasattr(self, 'declared_fieldsets') and self.declared_fieldsets) \ if hasattr(self, 'fieldsets') or hasattr(self, 'fields') or not self.base_fieldsets:
or not self.base_fieldsets:
return super(PolymorphicChildModelAdmin, self).get_fieldsets(request, obj) return super(PolymorphicChildModelAdmin, self).get_fieldsets(request, obj)
# Have a reasonable default fieldsets, # Have a reasonable default fieldsets,