Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

A Django framework for application-layer rate limiting

Project Description

a framework for implementing application-specific rate-limiting middleware for Django projects

What this module is intended for:

Implementing application-level (or just below) rate-limiting rules. Often, these rules would be expressed as “max # requests within a defined time period”. E.g.:

  • an IP address may make at most 1500 requests/day
  • users with an OAuth access token may make 500 reads/hour and 200 writes/hour

What it is not intended for:

A token bucket or leaky bucket filter: intended primarily for traffic shaping, those algorithms are implemented by firewalls and servers such as nginx.


  1. Install the library with pip:

    sudo pip install django-throttle-requests
  2. Add the directory throttle to your project’s PYTHONPATH.

  3. Insert the following configuration into your project’s settings:

        'default': {
            'NUM_BUCKETS':2,  # Number of buckets worth of history to keep. Must be at least 2
            'BUCKET_INTERVAL':15 * 60  # Period of time to enforce limits.
            'BUCKET_CAPACITY':50,  # Maximum number of requests allowed within BUCKET_INTERVAL
    # Where to store request counts.
    THROTTLE_BACKEND = 'throttle.backends.cache.CacheBackend'
    # Force throttling when DEBUG=True
  4. Use the @throttle decorator to enforce throttling rules on a view:

    from throttle.decorators import throttle
    def myview(request):
  5. Also works with class-based views:

    from throttle.decorators import throttle
    @method_decorator(throttle(zone='default'), name='dispatch')
    class TestView(View):
        def dispatch(self, *args, **kwargs):
            return super(TestView, self).dispatch(*args, **kwargs)
        def head(self, request):
        def get(self, request):
Release History

Release History

This version
History Node


History Node


History Node


History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-throttle-requests-0.5.4.tar.gz (6.2 kB) Copy SHA256 Checksum SHA256 Source Mar 27, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting