|
19 | 19 | """
|
20 | 20 | from __future__ import unicode_literals
|
21 | 21 |
|
| 22 | +import warnings |
| 23 | + |
22 | 24 | from django.conf import settings
|
23 | 25 | from django.test.signals import setting_changed
|
24 | 26 | from django.utils import six
|
|
135 | 137 | )
|
136 | 138 |
|
137 | 139 |
|
| 140 | +# List of settings that have been removed |
| 141 | +REMOVED_SETTINGS = ( |
| 142 | + "PAGINATE_BY", "PAGINATE_BY_PARAM", "MAX_PAGINATE_BY", |
| 143 | +) |
| 144 | + |
| 145 | + |
138 | 146 | def perform_import(val, setting_name):
|
139 | 147 | """
|
140 | 148 | If the given setting is a string import notation,
|
@@ -177,7 +185,7 @@ class APISettings(object):
|
177 | 185 | """
|
178 | 186 | def __init__(self, user_settings=None, defaults=None, import_strings=None):
|
179 | 187 | if user_settings:
|
180 |
| - self._user_settings = user_settings |
| 188 | + self._user_settings = self.__check_user_settings(user_settings) |
181 | 189 | self.defaults = defaults or DEFAULTS
|
182 | 190 | self.import_strings = import_strings or IMPORT_STRINGS
|
183 | 191 |
|
@@ -206,6 +214,13 @@ def __getattr__(self, attr):
|
206 | 214 | setattr(self, attr, val)
|
207 | 215 | return val
|
208 | 216 |
|
| 217 | + def __check_user_settings(self, user_settings): |
| 218 | + SETTINGS_DOC = "http://www.django-rest-framework.org/api-guide/settings/" |
| 219 | + for setting in REMOVED_SETTINGS: |
| 220 | + if setting in user_settings: |
| 221 | + warnings.warn("The '%s' setting has been removed. Please refer to '%s' for available settings." % (setting, SETTINGS_DOC), DeprecationWarning) |
| 222 | + return user_settings |
| 223 | + |
209 | 224 |
|
210 | 225 | api_settings = APISettings(None, DEFAULTS, IMPORT_STRINGS)
|
211 | 226 |
|
|
0 commit comments