Skip to main content

Happy decorators for Django is a set of decorators for Django apps

Project description

Django Happy Decorators

Build Status Coverage Status PyPI version Documentation Status License: MIT

Overview

Django Happy Decorators is a collection of useful decorators for Django.

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=3600, redirect_url='/rate_limit_exceeded', mode='ip')
def my_view(request):
    # View logic goes here

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


Download files

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

Source Distribution

django-happy-decorators-0.2.2.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_happy_decorators-0.2.2-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file django-happy-decorators-0.2.2.tar.gz.

File metadata

  • Download URL: django-happy-decorators-0.2.2.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.9

File hashes

Hashes for django-happy-decorators-0.2.2.tar.gz
Algorithm Hash digest
SHA256 5649add7b906b6ea041644f267a6f7526b4df0036f4d0b9049717bc33e66f371
MD5 2a806d4bf0f58830959efcc046f7a52a
BLAKE2b-256 e0432a5afddf97a6bb15594e9712b50080449ad2a29361f85ad5f00f768fd4c5

See more details on using hashes here.

File details

Details for the file django_happy_decorators-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for django_happy_decorators-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 235a629097e66447b11f7c234f26546f03f8fe6f1ffdd2ca368bbce358bb2dbe
MD5 7cc0bc894723d81b5ac8c38214b215b0
BLAKE2b-256 9d66e7006866a9420efd3f3e71829535aae4449b0baae380ad250c46d12203a2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page