File: index.rst

package info (click to toggle)
python-django-ratelimit 4.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 348 kB
  • sloc: python: 892; makefile: 134; sh: 49
file content (84 lines) | stat: -rw-r--r-- 1,943 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
================
Django Ratelimit
================

Project
=======

**Django Ratelimit** is a ratelimiting decorator for Django views,
storing rate data in the configured `Django cache backend
<https://docs.djangoproject.com/en/dev/topics/cache/>`__.

.. image:: https://travis-ci.org/jsocol/django-ratelimit.png?branch=master
   :target: https://travis-ci.org/jsocol/django-ratelimit

:Code:          https://github.com/jsocol/django-ratelimit
:License:       Apache Software License
:Issues:        https://github.com/jsocol/django-ratelimit/issues
:Documentation: http://django-ratelimit.readthedocs.org/


Quickstart
==========

.. warning::
   `django_ratelimit` requires a Django cache backend that supports `atomic
   increment`_ operations. The Memcached and Redis backends do, but the
   database backend does not. More information can be found in
   :ref:`Installation <installation-cache>`

Install:

.. code-block:: shell

   pip install django-ratelimit


Use as a decorator in ``views.py``:

.. code-block:: python

    from django_ratelimit.decorators import ratelimit

    @ratelimit(key='ip')
    def myview(request):
        # ...

    @ratelimit(key='ip', rate='100/h')
    def secondview(request):
        # ...

Before activating django-ratelimit, you should ensure that your cache
backend is setup to be both persistent and work across multiple
deployment worker instances (for instance UWSGI workers). Read more in
the Django docs on `caching
<https://docs.djangoproject.com/en/dev/topics/cache/>`__.

.. _PyPI: http://pypi.python.org/pypi/django-ratelimit
.. _atomic increment: https://docs.djangoproject.com/en/4.1/topics/cache/#django.core.caches.cache.incr


Contents
========

.. toctree::
   :maxdepth: 2

   installation
   settings
   usage
   keys
   rates
   security
   upgrading
   contributing
   cookbook/index


Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`