I am having the same problem as in this question (dj-rest-auth/registration return http 204 no content) but it still hasnt been answered so I wanted to post a new one to update it so maybe someone can give a solution.
I were following the book Django for APIs by William.S.Vincent. In Chapter 8: User Authentication, I make Implementing token authentication and use dj-rest-auth and django-allauth to make registration. In the book after register the http return 201 created, it created new account and return API auth key token, save that in db. enter image description here
With my it return http 204 no content( not return API auth key token ), it still created a new account but don't create key token for account.
My url.py
urlpatterns = [
path('admin/', admin.site.urls),
path('api/v1/', include("posts.urls")), # v1 for api version 1. (Name for each api route)
path('api-auth/', include('rest_framework.urls')), # build-in log in/out rest
path("api/v1/dj-rest-auth/", include("dj_rest_auth.urls")), #url for dj_rest_auth
path("api/v1/dj-rest-auth/registration/", include("dj_rest_auth.registration.urls")),
]
My settings.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
#3party
"rest_framework",
"corsheaders",
"rest_framework.authtoken",
"allauth",
"allauth.account",
"allauth.socialaccount",
"dj_rest_auth",
"dj_rest_auth.registration",
#local
'accounts.apps.AccountsConfig',
'posts.apps.PostsConfig',]
REST_FRAMEWORK = { # new
"DEFAULT_PERMISSION_CLASSES": [
"rest_framework.permissions.IsAuthenticated",
],
"DEFAULT_AUTHENTICATION_CLASSES": [
"rest_framework.authentication.SessionAuthentication",
"rest_framework.authentication.TokenAuthentication",
],}
I compared with github files both author and found no difference. github:https://github.com/wsvincent/restapiswithdjango/tree/master/ch8-blog-user-auth
Someone commented to add this but it is not a solution, its just turning off session authenitcation (SESSION_LOGIN: false)
Please someone help with this. Thank you
Did you run
python manage.py migrateafter adding "rest_framework.authtoken" to INSTALLED_APPS ?