mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-02 11:30:12 +03:00
Merge b8a2d6c9d8
into d7224afe54
This commit is contained in:
commit
6d0977fd8d
|
@ -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
|
||||||
|
|
|
@ -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`.
|
||||||
|
|
|
@ -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,
|
||||||
}
|
}
|
||||||
|
|
|
@ -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):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user