Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Possible Problem Throttle #9706

Unanswered
williank asked this question in Potential Issue
Discussion options

The text in the documentation suggests that we can use the attribute throttle_classes=[UserRateThrottle] In the decorator @action, however, this does not seem to be true. Because the action decorator does not recognize the throttle_classes.

I tested countless ways until I came to this conclusion.

https://www.django-rest-framework.org/api-guide/throttling/

It's also possible to set throttle classes for routes that are created using the @action decorator. Throttle classes set in this way will override any viewset level class settings.

@action(detail=True, methods=["post"], throttle_classes=[UserRateThrottle])
def example_adhoc_method(request, pk=None):
 content = {
 'status': 'request was permitted'
 }
 return Response(content)
You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /