Removed Settings raise attribute error

This commit is contained in:
Luis San Pablo 2015-12-07 21:45:44 -06:00
parent f3949e994d
commit d86a901aff

View File

@ -177,7 +177,7 @@ class APISettings(object):
""" """
def __init__(self, user_settings=None, defaults=None, import_strings=None): def __init__(self, user_settings=None, defaults=None, import_strings=None):
if user_settings: if user_settings:
self._user_settings = user_settings self._user_settings = self.__check_user_settings(user_settings)
self.defaults = defaults or DEFAULTS self.defaults = defaults or DEFAULTS
self.import_strings = import_strings or IMPORT_STRINGS self.import_strings = import_strings or IMPORT_STRINGS
@ -206,6 +206,14 @@ class APISettings(object):
setattr(self, attr, val) setattr(self, attr, val)
return val return val
def __check_user_settings(self, user_settings):
DEPRECEATED_SETTINGS = (
"PAGINATE_BY", "PAGINATE_BY_PARAM", "MAX_PAGINATE_BY_SET",)
SETTINGS_DOC = "http://www.django-rest-framework.org/api-guide/settings/"
for setting in DEPRECEATED_SETTINGS:
if setting in user_settings:
raise AttributeError("The '%s' setting has been removed. Please refer to '%s' for available settings." % setting, SETTINGS_DOC)
api_settings = APISettings(None, DEFAULTS, IMPORT_STRINGS) api_settings = APISettings(None, DEFAULTS, IMPORT_STRINGS)