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.
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
Has there been any change to the version? Thank for you time.