I Want Use packeage 'dj_rest_auth' in django-rest-framework for login but get error:
ImproperlyConfigured at /dj-rest-auth/login/ No default throttle rate set for 'dj_rest_auth' scope
In setting.py File:
INSTALLED_APPS = [
...
# 3rd Party
'rest_framework',
'rest_framework.authtoken',
'rest_framework_simplejwt',
'dj_rest_auth',
# local
...
]
REST_USE_JWT = True
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES':[
'rest_framework_simplejwt.authentication.JWTAuthentication',
'dj_rest_auth.jwt_auth.JWTCookieAuthentication',
],
'DEFAULT_PERMISSION_CLASSES':[
'rest_framework.permissions.AllowAny'
],
'DEFAULT_RENDERER_CLASSES':[
'rest_framework.renderers.JSONRenderer'
],
'DEFAULT_THROTTLE_CLASSES':[
'rest_framework.throttling.AnonRateThrottle',
'rest_framework.throttling.UserRateThrottle',
'rest_framework.throttling.ScopedRateThrottle',
],
'DEFAULT_THROTTLE_RATES':{
'anon':'50/hour',
'user':'200/hour',
'register':'5/hour',
'ref_token':'5/minute',
'create_article':'5/minute',
}
}
And url.py:
urlpatterns = [ ... path('dj-rest-auth/',include('dj_rest_auth.urls')), ]
TL;DR Add this into your settings.py file
'DEFAULT_THROTTLE_RATES': {
'dj_rest_auth': '10000/day',
...
},
or set the throttle_scope
within the view to something else like anon
.
Experienced the same issue and found this line within the project code
The view sets a custom throttle scope which you would not have configured within the REST_FRAMEWORK
section of the settings.py
file hence the error. No idea why they would make this change and not document it correctly.