Skip to content

Add @throttle_scope function based view decorator#9963

Open
d-ryzhykau wants to merge 1 commit intoencode:mainfrom
d-ryzhykau:throttle_scope-decorator
Open

Add @throttle_scope function based view decorator#9963
d-ryzhykau wants to merge 1 commit intoencode:mainfrom
d-ryzhykau:throttle_scope-decorator

Conversation

@d-ryzhykau
Copy link
Copy Markdown

The new decorator allows to set throttle scope for function based views. The implementation was suggested in #9942.

The change includes a test for the new decorator and mention of it in the docs.

@d-ryzhykau d-ryzhykau marked this pull request as draft April 24, 2026 00:49
@d-ryzhykau d-ryzhykau force-pushed the throttle_scope-decorator branch from f80dcb4 to 0513735 Compare April 24, 2026 01:44
@d-ryzhykau d-ryzhykau marked this pull request as ready for review April 24, 2026 01:49
Comment thread docs/api-guide/views.md

Each of these decorators is equivalent to setting their respective [api policy attributes][api-policy-attributes].

All decorators take a single argument. The ones that end with `_class` expect a single class while the ones ending in `_classes` expect a list or tuple of classes.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line doesn't work for this new decorator... Can we rephrase or add another sentence?

Comment thread tests/test_decorators.py
Comment on lines +163 to +164
@throttle_classes([OncePerDayScopedThrottle])
@throttle_scope(scope)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is @throttle_classes required every time @throttle_scope is used? I don't think so if the scopes are defined in the project settings... Can we add a test to cover that please?

Also make sure we're aligned with CBV in terms of misconfigurations (e.g specifying an unknown scope)

@browniebroke browniebroke added this to the 3.18 milestone Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants