Muhammad AbdulMoiz
Software Developer at Sastaticket.pk
Author: Muhammad AbdulMoiz
Author: Muhammad AbdulMoiz
Muhammad AbdulMoiz
Software Engineer @
Author: Muhammad AbdulMoiz
Understanding Throttling
Django Throttling policy
Throttle types
Dig down in implementation
REST_FRAMEWORK = { 'DEFAULT_THROTTLE_CLASSES': [ 'rest_framework.throttling.AnonRateThrottle', 'rest_framework.throttling.UserRateThrottle' ], 'DEFAULT_THROTTLE_RATES': { 'anon': '100/day', 'user': '1000/day' } }
from rest_framework.response import Response
from rest_framework.throttling import UserRateThrottle
from rest_framework.views import APIView
class ExampleView(APIView):
throttle_classes = [UserRateThrottle]
def get(self, request, format=None):
content = {
'status': 'request was permitted'
}
return Response(content)
@api_view(['GET']) @throttle_classes([UserRateThrottle]) def example_view(request, format=None): content = { 'status': 'request was permitted' } return Response(content)
Annon Rate Throttle
User Rate Throttle
Scoped Throttle
Custom Throttle
Text
Text
By Muhammad AbdulMoiz
Understanding and implementing Django Throttline