Merge pull request #321 from skirsdeda/admin_fieldsets_fix
Do not use deprecated and removed declared_fieldsets attribute in adminfix_request_path_info
commit
0367d5f3ee
|
|
@ -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)
|
||||||
|
|
|
||||||
|
|
@ -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,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue