aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework
diff options
context:
space:
mode:
authorVal Neekman2014-02-27 12:27:54 -0800
committerVal Neekman2014-02-27 12:27:54 -0800
commit818b4bf8b354d43360e3fd9d0b10440636a25212 (patch)
tree5de421d6b2bfcfaa3744a72f1b492cf7e4881472 /rest_framework
parent6e92e415aa7dd6871ef7d6500a85cacebde8dca2 (diff)
downloaddjango-rest-framework-818b4bf8b354d43360e3fd9d0b10440636a25212.tar.bz2
handle negative time value and prevent a divide by zero
Diffstat (limited to 'rest_framework')
-rw-r--r--rest_framework/throttling.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/rest_framework/throttling.py b/rest_framework/throttling.py
index a946d837..efa9fb94 100644
--- a/rest_framework/throttling.py
+++ b/rest_framework/throttling.py
@@ -136,6 +136,8 @@ class SimpleRateThrottle(BaseThrottle):
remaining_duration = self.duration
available_requests = self.num_requests - len(self.history) + 1
+ if available_requests <= 0:
+ return None
return remaining_duration / float(available_requests)