diff --git a/docs/api-guide/throttling.md b/docs/api-guide/throttling.md index c157e1ecd..1ca146b51 100644 --- a/docs/api-guide/throttling.md +++ b/docs/api-guide/throttling.md @@ -222,6 +222,8 @@ Using `get_debounce_interval()`, one can e.g. ensure superusers can always invok return 0 return 5 +Note that due to the current implementation, debouncing _requires_ a throttling rate to be set as well. + [cite]: https://developer.twitter.com/en/docs/basics/rate-limiting [permissions]: permissions.md [identifying-clients]: http://oxpedia.org/wiki/index.php?title=AppSuite:Grizzly#Multiple_Proxies_in_front_of_the_cluster diff --git a/rest_framework/throttling.py b/rest_framework/throttling.py index dc2cde30c..bc1ca853e 100644 --- a/rest_framework/throttling.py +++ b/rest_framework/throttling.py @@ -67,6 +67,9 @@ class SimpleRateThrottle(BaseThrottle): debounce_interval = None def __init__(self): + # TODO: this should probably be deferred to `allow_request`, + # to simplify `ScopedRateThrottle` as well as to allow debouncing + # without rate limiting. if not getattr(self, 'rate', None): self.rate = self.get_rate() self.num_requests, self.duration = self.parse_rate(self.rate)