Reputation: 585
When I run python manage.py migrate
command, I am having the following error:
ImportError: Could not import 'rest_framework.authentications.SessionAuthentiation' for API setting 'DEFAULT_AUTHENTICATION_CLASSES'.
ModuleNotFoundError: No module named 'rest_framework.authentications'.
Rest-framework-related parts of my code:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# 3rd party
'rest_framework',
'rest_framework.authtoken',
# Local
'posts.apps.PostsConfig',
]
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAuthenticated',
],
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentications.SessionAuthentiation',
'rest_framework.authentications.TokenAuthentication',
],
}
I am reading and going along with Django for APIs by W. S. Vincent.
Upvotes: 0
Views: 1221
Reputation: 2019
Check the documentation : https://www.django-rest-framework.org/api-guide/authentication/#setting-the-authentication-scheme
It says :
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.BasicAuthentication',
'rest_framework.authentication.SessionAuthentication',
]
}
Change rest_framework.authentications
to rest_framework.authentication
in your case. Remove the trailing s
.
Upvotes: 3