django-ratelimit
Cache-based rate-limiting for Django.
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-ratelimituv
uv add django-ratelimitpoetry
poetry add django-ratelimitInstalling 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
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
ratelimitA function decorator that enforces rate limits…
permissive · top 5,000 on PyPI
ratelimiterEnforces rate limiting on function calls and…
permissive · top 15,000 on PyPI
fastapi-limiterAdds request rate limiting to FastAPI routes…
permissive · top 5,000 on PyPI
requests-ratelimiterAdds rate-limiting to the requests library by…
permissive · top 5,000 on PyPI
ratelimRatelim enforces rate limits on function calls…
permissive · top 5,000 on PyPI
Flask-LimiterFlask-Limiter adds rate limiting to Flask…
permissive · top 1,000 on PyPI
apeyeapeye provides pathlib-like URL objects, a…
copyleft · top 5,000 on PyPI
django-axesdjango-axes tracks failed login attempts to…
permissive · top 5,000 on PyPI
django-defenderBlocks brute-force login attempts in Django by…
permissive · top 15,000 on PyPI
jasonProvides lightweight helper functions for…
copyleft · top 15,000 on PyPI