Throttle classes¶
Async-aware throttle classes that use Django's async cache. See the Throttling guide for cache-backend selection and per-action scoping.
BaseThrottle ¶
Bases: BaseThrottle
All throttle classes should extend BaseThrottle. Adds an async aallow_request hook that defaults to running the sync allow_request in a thread.
aallow_request
async
¶
Returns True if the request should be allowed, False otherwise.
SimpleRateThrottle ¶
Bases: BaseThrottle, SimpleRateThrottle
A simple cache implementation of a rate limit throttle. Adds an async surface that uses Django's async cache so rate limiting does not block the event loop.
AnonRateThrottle ¶
Bases: SimpleRateThrottle, AnonRateThrottle
Limits the rate of API calls that may be made by an anonymous user. Inherits SimpleRateThrottle's async cache path.
UserRateThrottle ¶
Bases: SimpleRateThrottle, UserRateThrottle
Limits the rate of API calls that may be made by a given user. Inherits SimpleRateThrottle's async cache path.
ScopedRateThrottle ¶
Bases: SimpleRateThrottle, ScopedRateThrottle
Limits the rate of API calls by different amounts for various parts of the API. Inherits SimpleRateThrottle's async cache path.