Happy decorators for Django is a set of decorators for Django apps and views to make your life easier.
Project description
Django Happy Decorators
Overview
Happy decorators for Django is a set of decorators for Django apps and views to make your life easier.
Decorators
rate_limit: Rate limit a view function based on IP address, user or all requests.
Installation
You can install Django Rate Limit using pip:
pip install django_happy_decorators
Usage
To use the rate_limit decorator, import it from the package and apply it to a view function. The decorator accepts three parameters: num_requests, time_frame and redirect_url.
from django_rate_limit.decorators import rate_limit
@rate_limit(num_requests=100, time_frame=60, redirect_url='/rate_limit_exceeded', mode='ip')
def my_view(request):
# View logic goes here
The previous example will limit the number of requests to the view to 100 per hour. If the limit is reached, the user will be redirected to '/rate_limit_exceeded'.
Other Example:
from django_rate_limit.decorators import rate_limit
@rate_limit(num_requests=10000, time_frame=1, redirect_url='/rate_limit_exceeded', mode='all')
def my_view(request):
# View logic goes here
The previous example will limit the number of requests to the view to 10k/min (10000 requests per minute). If the limit is reached, the user will be redirected to '/rate_limit_exceeded'. This could be useful if you know your server limits and want to prevent it from crashing."
Modes:
- ip: limits the number of requests per IP address
- user: limits the number of requests per user
- all: limits the number of requests
In the example above, the view will only allow 100 requests per hour and when the limit is reached it will redirect the user to '/rate_limit_exceeded'
Documentation
For more information on how to use Django Rate Limit, please refer to the documentation at:
https://django-rate-limit.readthedocs.io/
Contributing
We welcome contributions to Django Rate Limit. If you want to contribute, please read our contributing guidelines for more information.
License
Django Rate Limit is released under the MIT License.
This is just a sample and you can adjust the content as per your package and also add more details like screenshots, sample code etc.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django-happy-decorators-0.2.3.tar.gz.
File metadata
- Download URL: django-happy-decorators-0.2.3.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a839f24fd757b11d7dd43868a2a6d1dd3f3c2a417770b6c978829feb31cae7b
|
|
| MD5 |
26480657cc107bf60aed6ef874185ad4
|
|
| BLAKE2b-256 |
ab748323195e8b4cb6605f6884b49de299b446c7074e1687268a848b2b7ced35
|
File details
Details for the file django_happy_decorators-0.2.3-py3-none-any.whl.
File metadata
- Download URL: django_happy_decorators-0.2.3-py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
523cf405fa01aee2365245b8a36e457c4e196122c8987481fee9e2415f61eea3
|
|
| MD5 |
f7790c901f87c1bfb899546156539251
|
|
| BLAKE2b-256 |
04800d5e936816aee35f873e57a32fb4a3ffe3af491890b6ae4594d85eeb370d
|