This commit is contained in:
CHI Cheng 2013-08-28 04:58:16 -07:00
commit 6d0977fd8d
4 changed files with 12 additions and 1 deletions

View File

@ -70,6 +70,12 @@ Or, if you're using the `@api_view` decorator with function based views.
The throttle classes provided by REST framework use Django's cache backend. You should make sure that you've set appropriate [cache settings][cache-setting]. The default value of `LocMemCache` backend should be okay for simple setups. See Django's [cache documentation][cache-docs] for more details. The throttle classes provided by REST framework use Django's cache backend. You should make sure that you've set appropriate [cache settings][cache-setting]. The default value of `LocMemCache` backend should be okay for simple setups. See Django's [cache documentation][cache-docs] for more details.
You could select the cache to use, using the `THROTTLE_CACHE_ALIAS` setting. For example.
REST_FRAMEWORK = {
'THROTTLE_CACHE_ALIAS': 'default'
}
--- ---
# API Reference # API Reference

View File

@ -43,6 +43,7 @@ You can determine your currently installed version using `pip freeze`:
### Master ### Master
* Support customizable view name and description functions, using the `VIEW_NAME_FUNCTION` and `VIEW_DESCRIPTION_FUNCTION` settings. * Support customizable view name and description functions, using the `VIEW_NAME_FUNCTION` and `VIEW_DESCRIPTION_FUNCTION` settings.
* Add `THROTTLE_CACHE_ALIAS` option to choose throttle cache.
* Bugfix: `required=True` argument fixed for boolean serializer fields. * Bugfix: `required=True` argument fixed for boolean serializer fields.
* Bugfix: `client.force_authenticate(None)` should also clear session info if it exists. * Bugfix: `client.force_authenticate(None)` should also clear session info if it exists.
* Bugfix: Client sending emptry string instead of file now clears `FileField`. * Bugfix: Client sending emptry string instead of file now clears `FileField`.

View File

@ -109,6 +109,8 @@ DEFAULTS = {
), ),
'TIME_FORMAT': None, 'TIME_FORMAT': None,
'THROTTLE_CACHE_ALIAS': 'default',
# Pending deprecation # Pending deprecation
'FILTER_BACKEND': None, 'FILTER_BACKEND': None,
} }

View File

@ -2,11 +2,13 @@
Provides various throttling policies. Provides various throttling policies.
""" """
from __future__ import unicode_literals from __future__ import unicode_literals
from django.core.cache import cache from django.core.cache import get_cache
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
from rest_framework.settings import api_settings from rest_framework.settings import api_settings
import time import time
cache = get_cache(api_settings.THROTTLE_CACHE_ALIAS)
class BaseThrottle(object): class BaseThrottle(object):
""" """