22๐
โ
My problem was in my settings.py file:
Diff:
REST_FRAMEWORK = {
- 'DEFAULT_AUTHENTICATION_CLASSES': {
+ 'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.SessionAuthentication',
- }
+ ),
- 'DEFAULT_PERMISSION_CLASSES': {
+ 'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAuthenticatedOrReadOnly',
- },
+ ),
}
๐คLeon Wright
10๐
Just want to give an example from the previous correct answers with Django v2.0.6 and Django REST framework v3.8.2.
For example in settings.py:
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': {
'rest_framework.authentication.BasicAuthentication',
'rest_framework.authentication.SessionAuthentication',
}
}
Change:
'DEFAULT_AUTHENTICATION_CLASSES': {
'rest_framework.authentication.BasicAuthentication',
'rest_framework.authentication.SessionAuthentication',
}
Into:
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.BasicAuthentication',
'rest_framework.authentication.SessionAuthentication',
)
By just replacing the โ{ }โ with โ( )โ.
๐คSteven
- How to return data with 403 error in Django Rest Framework?
- How to find out the summarized text of a given URL in python / Django?
- How do I remove the square brackets at the end of a JS variable name during AJAX calls?
2๐
if you are using simple_jwt also check this , donโt use these brackets {} but () and add comma at the end
SIMPLE_JWT = {
'AUTH_HEADER_TYPES': ('JWT',),
'ACCESS_TOKEN_LIFETIME': timedelta(minutes=100),
# 'ROTATE_REFRESH_TOKENS': False,
# 'BLACKLIST_AFTER_ROTATION': False,
# 'UPDATE_LAST_LOGIN': False,
'AUTH_TOKEN_CLASSES': ('rest_framework_simplejwt.tokens.AccessToken',),
}
- How to create a django ViewFlow process programmatically
- Python from django.contrib.auth.views import logout ImportError: cannot import name 'logout'
- How to use pytest fixtures with django TestCase
- Multiple lookup_fields for django rest framework
Source:stackexchange.com