API

Core

class djlimiter.Limiter[source]

Bases: object

process_request(request)[source]
Parameters:request
Returns:
process_response(request, response)[source]
Parameters:
  • request
  • response
Returns:

djlimiter.limit(limit_value, key_function=None, per_method=False)[source]

decorator to be used for rate limiting individual views

Parameters:
  • limit_value – rate limit string or a callable that returns a string. Rate limit string notation for more details.
  • key_func (function) – function/lambda to extract the unique identifier for the rate limit. defaults to remote address of the request.
  • per_method (bool) – whether the limit is sub categorized into the http method of the request.
djlimiter.exempt(fn)[source]

decorator to mark a view or all views in a blueprint as exempt from rate limits.

Parameters:fn – the view to wrap.
Returns:
djlimiter.shared_limit(limit_value, scope, key_function=None)[source]

decorator to be applied to multiple views sharing the same rate limit.

Parameters:
  • limit_value – rate limit string or a callable that returns a string. Rate limit string notation for more details.
  • scope – a string or callable that returns a string for defining the rate limiting scope.
  • key_func (function) – function/lambda to extract the unique identifier for the rate limit. defaults to remote address of the request.

Exceptions

exception djlimiter.RateLimitExceeded(limit)[source]

Bases: django.http.response.HttpResponse

exception raised when a rate limit is hit (status code: 429).