Dica 47 - DRF: djoser - Django REST framework
Github: https://github.com/rg3915/drf-example
https://djoser.readthedocs.io/en/latest/
pip install -U djoser
pip freeze | grep djoser >> requirements.txtConfigure INSTALLED_APPS
INSTALLED_APPS = (
'django.contrib.auth',
(...),
'rest_framework',
'rest_framework.authtoken', # <-- rode ./manage.py migrate
'djoser', # <--
(...),
)
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.BasicAuthentication',
'rest_framework.authentication.TokenAuthentication',
),
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAuthenticated',
)
}
Configure urls.py
Veja no video como rodar no Postman e no Swagger.
Exemplos com curl
Quando faz o logout ele apaga o token, e só gera um novo quando você fizer login novamente.
PreviousDica 46 - DRF: drf-yasg - Yet another Swagger generatorNextDica 48 - DRF: Reset de Senha com djoser - Django REST framework
Last updated
Was this helpful?