Update documentation

example won't work without importing random module
This commit is contained in:
Reza Shalbaf Zadeh 2016-08-06 18:08:55 +04:30 committed by GitHub
parent e7eccac6df
commit 564675e62f

View File

@ -185,6 +185,7 @@ If the `.wait()` method is implemented and the request is throttled, then a `Ret
The following is an example of a rate throttle, that will randomly throttle 1 in every 10 requests. The following is an example of a rate throttle, that will randomly throttle 1 in every 10 requests.
class RandomRateThrottle(throttling.BaseThrottle): class RandomRateThrottle(throttling.BaseThrottle):
import random
def allow_request(self, request, view): def allow_request(self, request, view):
return random.randint(1, 10) == 1 return random.randint(1, 10) == 1