Added Djoser

This commit is contained in:
Keannu Christian Bernasol 2023-06-26 19:10:04 +08:00
parent 83682bead6
commit ab7fb228e3
13 changed files with 340 additions and 3 deletions

View file

3
stude/accounts/admin.py Normal file
View file

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

6
stude/accounts/apps.py Normal file
View file

@ -0,0 +1,6 @@
from django.apps import AppConfig
class AccountsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'accounts'

View file

3
stude/accounts/models.py Normal file
View file

@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

3
stude/accounts/tests.py Normal file
View file

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

7
stude/accounts/urls.py Normal file
View file

@ -0,0 +1,7 @@
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('', include('djoser.urls')),
path('', include('djoser.urls.authtoken'))
]

3
stude/accounts/views.py Normal file
View file

@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.

View file

@ -2,5 +2,5 @@ from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('accounts/', include('accounts.urls'))
]

View file

@ -42,6 +42,8 @@ INSTALLED_APPS = [
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'djoser',
'rest_framework.authtoken',
]
MIDDLEWARE = [
@ -72,6 +74,18 @@ TEMPLATES = [
},
]
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication',
)
}
DJOSER = {
'SEND_ACTIVATION_EMAIL': True,
'SEND_CONFIRMATION_EMAIL': True,
'ACTIVATION_URL': 'activation/{uid}/{token}',
}
WSGI_APPLICATION = 'config.wsgi.application'
@ -85,6 +99,10 @@ DATABASES = {
}
}
EMAIL_HOST = str(os.getenv('EMAIL_HOST'))
EMAIL_HOST_USER = str(os.getenv('EMAIL_HOST_USER'))
EMAIL_HOST_PASSWORD = str(os.getenv('EMAIL_HOST_PASSWORD'))
EMAIL_PORT = str(os.getenv('EMAIL_PORT'))
# Password validation
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators

View file

@ -15,8 +15,9 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('api/v1/', include('api.urls'))
]