标签:elf setting framework cep turn def sim span request
-频率是什么?节流,访问控制 -内置的访问频率控制类SimpleRateThrottle -写一个类,继承SimpleRateThrottle -class MyThrottle(SimpleRateThrottle): scope=‘aaa‘ def get_cache_key(self, request, view): return self.get_ident(request) -在setting中: REST_FRAMEWORK = { ‘DEFAULT_THROTTLE_RATES‘:{ ‘aaa‘:‘10/m‘ } } -使用 局部使用: -在视图类中写 throttle_classes = [MyThrottle,] 全局使用: -在setting中写 ‘DEFAULT_THROTTLE_CLASSES‘:[‘app01.MyAuth.MyThrottle‘,], -局部禁用: -在视图类中写 throttle_classes = [] 错误信息改成中文显示: def throttled(self, request, wait): class MyThrottled(exceptions.Throttled): default_detail = ‘傻逼‘ extra_detail_singular = ‘还剩 {wait} 秒.‘ extra_detail_plural = ‘还剩 {wait} 秒‘ raise MyThrottled(wait)
标签:elf setting framework cep turn def sim span request
原文地址:https://www.cnblogs.com/xuqidong/p/13912351.html