Django Ratelimit vs Django REST framework Throttling

I'm currently using the Django Ratelimit library on my post method while using the APIView class.

I'm looking to see if I should integrate the throttling tool from Django REST framework.

After reading the DRF docs where it says: "Throttles do not necessarily only refer to rate-limiting requests", I've come to the conclusion that I'm not even sure if I understand what the differences are.

Therefore, I would like to know if they are almost the same, or when one should be used over the other and vice-versa.

1 answer

  • answered 2019-11-14 00:49 kumarm5

    Throttling:

    This functionality is already in the Django rest framework, you don't have to install other packages for this.

    In throttle, you can use a different type of throttling, like AnonRateThrottle, UserRateThrottle, ScopedRateThrottle

    You can also write your own throttle class by extending the 'BaseThrottle' class.

    Django-Ratelimit:

    It is a different package, you have to install it in order to use it.

    Here, you can use @ratelimit decorator with limited parameters. like - @ratelimit(key='ip', rate='10/h') or you can extend your class by 'RatelimitMixin' class.