【发布时间】:2021-01-13 05:44:07
【问题描述】:
例如:为客户和员工设置不同的节流率。
这可以使用UserRateThrottle 来完成吗?例如:
REST_FRAMEWORK['DEFAULT_THROTTLE_CLASSES'] = ('backend.throttles.EmployeeThrottle')
REST_FRAMEWORK['DEFAULT_THROTTLE_RATES'] = {
'user': config.THROTTLE_RATE,
'employee': config.EMPLOYEE_THROTTLE_RATE
}
from rest_framework.throttling import UserRateThrottle
class EmployeeThrottle(UserRateThrottle):
*WHAT TO DO HERE?*
我能否在这个EmployeeThrottle 类中以某种方式获取请求并根据该请求内容设置范围。
编辑:例如:UserRateThrottle 在BurstRateThrottle 中,如果我能以某种方式获得请求,我可以根据它设置范围。
【问题讨论】:
标签: django django-rest-framework