Django REST Framework: "No default throttle rate set for 'signup' scope" even though scope is defined

I’m trying to apply custom throttling for the signup endpoint in my Django REST Framework API.

The goal is to allow only 5 signup attempts per hour for anonymous users.

I created a SignupRateThrottle class that sets scope = "signup" and included it in DEFAULT_THROTTLE_CLASSES. I also added "signup": "5/hour" inside DEFAULT_THROTTLE_RATES in my settings.py.

However, when I make a request to /api/v1/auth/signup/, I get this error:

ImproperlyConfigured: No default throttle rate set for 'signup' scope

Even though I already set the throttle rate for signup in my settings.

I’ve double-checked that:

The spelling of "signup" matches everywhere.

Restarting the server doesn’t fix it.

The error happens on a GET request, but I only intended to throttle POST requests.

What I expected:

Throttling should only apply to POST requests. After 5 signups in an hour, DRF should return 429 Too Many Requests.

What happens instead:

I get the ImproperlyConfigured error immediately.

What I tried:

Added "signup": "5/hour" in REST_FRAMEWORK["DEFAULT_THROTTLE_RATES"].

Restarted the server multiple times.

Verified that scope = "signup" matches in both the throttle class and settings.

Tried removing other custom throttles from DEFAULT_THROTTLE_CLASSES to isolate the issue

Setting the DEFAULT_THROTTLE_CLASSES sets the throttling logic globally, that's why you get it on GET requests.

*The default throttling policy may be set globally, using the DEFAULT_THROTTLE_CLASSES and DEFAULT_THROTTLE_RATES settings. (*https://www.django-rest-framework.org/api-guide/throttling)

To do it on a single view basis i suggest doing something like this...

#<app_name>/views.py
from <app_name>.throttles import MyThrottle

@api_view(['POST'])
@throttle_classes([MyThrottle])
def signup(request):
    #...

... and set just the DEFAULT_THROTTLE_RATES for 'signup' scope.

I couldn't recreate the Improperly configured behaviour you mentioned. I'd make sure you created your Throttle class correctly, and the variables are set inside the REST_FRAMEWORK variable.

This is the implementation that worked on my end:

#<app_name>/throttles.py
from rest_framework.throttling import AnonRateThrottle

class MyThrottle(AnonRateThrottle):
    scope = 'custom'
#settings.py

REST_FRAMEWORK = {
    'DEFAULT_THROTTLE_RATES': {
        'custom': '1/min'
    }}

Hope this helps.

Вернуться на верх