Bird
0
0

You want to create a custom throttle class that limits requests based on the user's subscription level. Which method should you override to customize the rate dynamically?

hard📝 Application Q9 of 15
Django - DRF Advanced Features
You want to create a custom throttle class that limits requests based on the user's subscription level. Which method should you override to customize the rate dynamically?
Await(self)
Bget_rate(self, request, view)
Callow_request(self, request, view)
Dthrottle_scope(self)
Step-by-Step Solution
Solution:
  1. Step 1: Identify method for dynamic rate

    get_rate is used to return the throttle rate string dynamically based on request or view.
  2. Step 2: Confirm other methods

    allow_request checks if request allowed, wait returns wait time, throttle_scope is an attribute, not method.
  3. Final Answer:

    get_rate(self, request, view) -> Option B
  4. Quick Check:

    Dynamic throttle rate set by overriding get_rate [OK]
Quick Trick: Override get_rate to set dynamic throttle limits [OK]
Common Mistakes:
MISTAKES
  • Overriding allow_request instead of get_rate
  • Confusing throttle_scope attribute with method
  • Trying to override wait for rate changes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes