Skip to content

Instantly share code, notes, and snippets.

@weinbergdavid
Last active January 15, 2019 16:46
Embed
What would you like to do?
from ratelimit.decorators import ratelimit
@ratelimit(key='post:username', rate='10/d') # 1
def login(request):
# ... yout logic here
pass
@ratelimit(key='ip', rate='1000/h') # 2
def login(request):
# ... yout logic here
pass
rate = lambda request: None if request.user.is_authenticated() else '100/h'
key = lambda request: request.POST["search_type"]
@ratelimit(key=key, rate=rate) # 3
def search(request):
# ... yout logic here
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment