Last active
December 20, 2015 13:49
-
-
Save loic/6141793 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py | |
| index d09aae8..ae712e7 100644 | |
| --- a/django/contrib/admin/options.py | |
| +++ b/django/contrib/admin/options.py | |
| @@ -1,6 +1,7 @@ | |
| import copy | |
| import operator | |
| from functools import partial, reduce, update_wrapper | |
| +import warnings | |
| from django import forms | |
| from django.conf import settings | |
| @@ -238,14 +239,20 @@ class BaseModelAdmin(six.with_metaclass(RenameBaseModelAdminMethods)): | |
| return db_field.formfield(**kwargs) | |
| - @property | |
| - def declared_fieldsets(self): | |
| - # This property exists for backward compatibility only. | |
| + def _declared_fieldsets(self): | |
| + warnings.warn( | |
| + "ModelAdmin.declared_fieldsets is deprecated and" | |
| + "will be removed in Django 1.9.", | |
| + PendingDeprecationWarning, 2 | |
| + ) | |
| + | |
| if self.fieldsets: | |
| return self.fieldsets | |
| elif self.fields: | |
| return [(None, {'fields': self.fields})] | |
| return None | |
| + _declared_fieldsets.deprecated = True | |
| + declared_fieldsets = property(_declared_fieldsets) | |
| def get_fields(self, request, obj=None): | |
| """ | |
| @@ -257,6 +264,15 @@ class BaseModelAdmin(six.with_metaclass(RenameBaseModelAdminMethods)): | |
| """ | |
| Hook for specifying fieldsets. | |
| """ | |
| + if not hasattr(self.declared_fieldsets, 'deprecated'): | |
| + warnings.warn( | |
| + "ModelAdmin.declared_fieldsets is deprecated and" | |
| + "will be removed in Django 1.9.", | |
| + PendingDeprecationWarning, 2 | |
| + ) | |
| + if self.declared_fieldsets: | |
| + return self.declared_fieldsets | |
| + | |
| if self.fieldsets: | |
| return self.fieldsets | |
| return [(None, {'fields': self.get_fields(request, obj)})] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment