skillfed

django-ratelimit

Cache-based rate-limiting for Django.

django-ratelimit v4.1.0 2.7M downloads/30d#2,926 on PyPI1,145
Permissive license Copyright (c) 2022, James Socol Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License… (full text in the JSON record) DORMANT released

What it is and what it does

Django Ratelimit is a lightweight decorator-based rate-limiting library for Django views. It enforces request limits by tracking access patterns in Django's cache backend, allowing you to throttle views based on IP address or custom request fields. The library is designed to protect views from abuse by rejecting requests that exceed a specified rate.

The package has been stable since its initial release and supports Python 3.7, 3.8, 3.9, 3.10, and 3.11. It carries no external runtime dependencies beyond Django itself, making it straightforward to integrate into existing projects. Maintenance is dormant but the codebase is marked Production/Stable and sees substantial real-world use.

Use it for:

  • Protect API endpoints from brute-force attacks by limiting requests per IP address
  • Throttle user-submitted form submissions to prevent spam or resource exhaustion
  • Enforce fair-use policies on public endpoints by rate-limiting per authenticated user or session
  • Prevent scraping or automated access to sensitive views by capping request frequency
  • Implement tiered access control where different endpoints have different rate limits

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides a Django decorator to rate-limit views based on IP address or request fields (GET/POST variables).

Yes. The package is production-stable, dependency-free, and widely used. Dormant maintenance is not a blocker for a mature, single-purpose tool with no known vulnerabilities. Install if you need straightforward IP- or field-based rate-limiting in Django; consider alternatives only if you need advanced features like distributed rate-limiting across multiple servers or async view support.

Install

django-ratelimit on PyPI

pip

pip install django-ratelimit

uv

uv add django-ratelimit

poetry

poetry add django-ratelimit

Installing django-ratelimit

Before you install

Low friction install with no runtime dependencies. Dormant maintenance status (last commit 2024-07-11, no releases in over 1 year), but marked Production/Stable and actively used across millions of monthly downloads.

License in practice

Apache Software License 2.0 (permissive). You may use, modify, and distribute this package freely in commercial and private projects, provided you include the license notice.

Quickstart

pip install django-ratelimit

from django_ratelimit.decorators import ratelimit

@ratelimit(key='ip', rate='10/h')
def my_view(request):
    return HttpResponse('OK')

Requires Django and Python 3.7 or later; rate-limiting depends on Django's cache framework being configured.

Verify before relying

  • Whether rate-limit state persists across Django cache backends or is limited to specific cache types
  • Whether the decorator supports async Django views or only synchronous views
  • Specific rate-limit format syntax and supported time windows beyond the examples in documentation

Package facts

License Copyright (c) 2022, James Socol Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License… (full text in the JSON record) (permissive)
Python support supports the current Python release (>=3.7)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance dormant — 1,117 days since the last release
Last repo commit
First released
Downloads 2,711,339/month — #2,926 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: django_ratelimit-4.1.0-py2.py3-none-any.whl

Development Status :: 5 - Production/StableEnvironment :: Web EnvironmentFramework :: DjangoIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python Modules

Tags

django rate limiting decoratorlimit requests per ipdjango view throttlingcache-based rate limitingdjango request throttleprevent api abusedjango rate limit views
rate-limitingdjango-middlewareapi-protection

More Python Modules packages