django check how many throttle limit i have left in
Django does not have any built-in throttle limit feature. However, if you are using a third-party library for throttling, the library may provide a way to check how many throttle limits are left.
For example, if you are using the django-rest-framework-throttle library, you can use the throttle_scope decorator to specify the scope of the throttle and the throttle attribute to access the current throttle instance. The throttle instance has a allow_request(request, view) method that returns None if the request is allowed or a HttpResponse instance with a Retry-After header if the request is throttled.
To check how many throttle limits are left, you can use the throttle.get_rate() method to get the current rate and the throttle.get_num_requests(request) method to get the number of requests made by the current user in the current rate limit window. You can then subtract the number of requests made from the rate limit to get the number of throttle limits left.
原文地址: https://www.cveoy.top/t/topic/brEs 著作权归作者所有。请勿转载和采集!