I am trying to use ratelimit in my Django site to restrict the number of requests from one IP in some time. Following is what I am trying.
urls.py
url(r'^test/$', 'myapp.views.test', name='myapp.views.test'),
views.py
@ratelimit(key='ip', rate='5/m')
def test(request):
return HttpResponse("Request submitted successfully.")
When I am trying to hit the url - http://:8080/test/ it is giving me the following error.
ValueError at /test/
Key 'rl:bbbcf11eb514e3e14d9472f112fc06b0' not found
Request Method: GET Request URL: http://:8080/test/ Django Version: 1.6 Exception Type: ValueError Exception Value:
Key 'rl:bbbcf11eb514e3e14d9472f112fc06b0' not found
I am trying to use document at - http://django-ratelimit.readthedocs.org/en/latest/index.html
There is something regarding setting RATELIMIT_USE_CACHE
in settings.py, but not sure what should be set in this setting. I am relatively new to the Django
Seems that ratelimit needs to use the Django Cache Framework to store the information about IPs and requests.
You'll need to setup some sort of cache, preferably memcached to use it. Hope that helps!