-
Notifications
You must be signed in to change notification settings - Fork 194
Description
Issue Description
When applying the @method_decorator(ratelimit(key="user", rate="2/h", block=True), name="change_password") decorator to a method within a class-based view, the custom error message defined in RATELIMIT_VIEW is not being thrown. However, when the same decorator is applied to a function-based view, it works as expected.
Steps to Reproduce
- Define a class-based view with a method decorated with
@method_decorator(ratelimit(key="user", rate="2/h", block=True), name="change_password"). - Ensure
RATELIMIT_VIEWis properly defined with a custom error message. - Attempt to trigger the rate limit by invoking the method.
Expected Behavior
The custom error message defined in RATELIMIT_VIEW should be thrown when the rate limit is exceeded, regardless of whether the view is class-based or function-based.
Actual Behavior
The custom error message is not thrown ( does throw permission denied ) when the rate limit is exceeded in a class-based view, while it works correctly in a function-based view.
Additional Information
- Package version: 4.1.0
Workarounds Tried
- Applying the decorator directly to URLs or the entire class view and it worked but resulted in loss of flexibility for different methods.
Note: This issue affects the flexibility and consistency of rate limiting in class-based views compared to function-based views.