This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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