文档说该句号应该是以下之一:('s', 'sec', 'm', 'min', 'h', 'hour', 'd', 'day')
。我很好奇我是否可以将句点设置为1/10min
?
答案 0 :(得分:1)
查看code和documentation,您无法开箱即用。但我确实看到了根据现有的custom throttle创建自己的的可能性:
from rest_framework.throttling import AnonRateThrottle
class AnonTenPerTenMinutesThrottle(AnonRateThrottle):
def parse_rate(self, rate):
"""
Given the request rate string, return a two tuple of:
<allowed number of requests>, <period of time in seconds>
So we always return a rate for 10 request per 10 minutes.
Args:
string: rate to be parsed, which we ignore.
Returns:
tuple: <allowed number of requests>, <period of time in seconds>
"""
return (10, 600)