django-rated - Rate Limiting made easy

https://travis-ci.org/funkybob/django-rated.png https://pypip.in/d/django-rated/badge.png https://pypip.in/v/django-rated/badge.png

Rated provides fine-grained rate limiting controls for Django.

It allows you do define multiple “realms”, each with its own limit, allowed list, and responses.

There are two mechanisms, which can be used individually, or combined:

  1. Middlware that lets you assign url patterns into realms.
  2. Decorators that let you rate limit views individually.

Quickstart

  1. Set your limits
RATED_DEFAULT_REALM = 'default'
# Duration over which we count requests
RATED_DEFAULT_DURATION = 60 * 60
# Maximum number of requests in DURATION period
RATED_DEFAULT_LIMIT = 100
  1. Decorate your views
@rate_limit
def my_view(request, ...)

@rate_limit('special')
def special_view(request, ...)