Implement Djoser library to handle users

This commit is contained in:
Francesco Esposito 2019-11-26 11:40:45 +01:00
parent a181de664f
commit c31c36e768
2 changed files with 12 additions and 13 deletions

View File

@ -38,6 +38,7 @@ INSTALLED_APPS = [
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'djoser',
'corsheaders',
'segnalibre_app'
]
@ -136,4 +137,8 @@ REST_FRAMEWORK = {
),
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
'PAGE_SIZE': 10
}
}
SIMPLE_JWT = {
'AUTH_HEADER_TYPES': ('JWT'),
}

View File

@ -1,18 +1,12 @@
from django.urls import path, include
from django.conf.urls import url
from . import views
from rest_framework_simplejwt.views import (
TokenObtainPairView,
TokenRefreshView,
TokenVerifyView)
prefix = 'v1/'
urlpatterns = [
path(prefix + 'users/', views.UserList.as_view()),
path(prefix + 'books/', views.BookList.as_view()),
path(prefix +'books/<int:pk>/', views.BookDetail.as_view()),
path('api-auth/', include('rest_framework.urls')),
path(prefix + 'auth/token', TokenObtainPairView.as_view(), name='token_obtain_pair'),
path(prefix + 'auth/refresh', TokenRefreshView.as_view(), name='token_refresh'),
path(prefix + 'auth/verify', TokenVerifyView.as_view(), name='token_verify')
url(r'^v1/auth/', include('djoser.urls')),
url(r'^v1/auth/', include('djoser.urls.jwt')),
path('v1/books/', views.BookList.as_view()),
path('v1/books/<int:pk>/', views.BookDetail.as_view()),
#path('api-auth/', include('rest_framework.urls')),
]