├── .idea ├── .gitignore ├── dataSources.xml ├── django-authentication-course-01.Install.iml ├── inspectionProfiles │ └── profiles_settings.xml ├── jsLibraryMappings.xml ├── misc.xml ├── modules.xml └── vcs.xml ├── .python-version ├── README.md ├── core ├── __init__.py ├── admin.py ├── apps.py ├── forms.py ├── migrations │ └── __init__.py ├── models.py ├── tests.py └── views.py ├── db.sqlite3 ├── demo ├── __init__.py ├── asgi.py ├── settings.py ├── urls.py └── wsgi.py ├── frontend ├── base.html ├── includes │ └── navbar.html ├── pages │ └── home.html └── registration │ ├── login.html │ └── signup.html ├── manage.py ├── requirements.txt └── static ├── css └── main.css └── js └── main.js /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Editor-based HTTP Client requests 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml 9 | -------------------------------------------------------------------------------- /.idea/dataSources.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | sqlite.xerial 6 | true 7 | true 8 | $PROJECT_DIR$/demo/settings.py 9 | org.sqlite.JDBC 10 | jdbc:sqlite:C:\Users\husan\OneDrive\Desktop\django-authentication-course-01.Install\db.sqlite3 11 | $ProjectFileDir$ 12 | 13 | 14 | -------------------------------------------------------------------------------- /.idea/django-authentication-course-01.Install.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 28 | 29 | 31 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/jsLibraryMappings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.python-version: -------------------------------------------------------------------------------- 1 | 3.10.4 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Django Authentication Course -------------------------------------------------------------------------------- /core/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hwandev12/django-authentication-app/cb3fbc50f9b1960cbd281cc7b042cddb20775961/core/__init__.py -------------------------------------------------------------------------------- /core/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from .models import CustomUser 3 | from .forms import CustomUserCreationForm, CustomUserChangeForm 4 | 5 | 6 | class CustomUserAdmin(admin.ModelAdmin): 7 | add_form = CustomUserCreationForm 8 | form = CustomUserChangeForm 9 | list_display = ['username', 'email'] 10 | 11 | 12 | admin.site.register(CustomUser, CustomUserAdmin) 13 | -------------------------------------------------------------------------------- /core/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class CoreConfig(AppConfig): 5 | default_auto_field = 'django.db.models.BigAutoField' 6 | name = 'core' 7 | -------------------------------------------------------------------------------- /core/forms.py: -------------------------------------------------------------------------------- 1 | from django.contrib.auth.forms import UserCreationForm, UserChangeForm 2 | from .models import CustomUser 3 | 4 | 5 | class CustomUserCreationForm(UserCreationForm): 6 | class Meta: 7 | model = CustomUser 8 | fields = ('username', 'email') 9 | 10 | 11 | class CustomUserChangeForm(UserChangeForm): 12 | class Meta: 13 | model = CustomUser 14 | fields = ('username', 'email') 15 | -------------------------------------------------------------------------------- /core/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hwandev12/django-authentication-app/cb3fbc50f9b1960cbd281cc7b042cddb20775961/core/migrations/__init__.py -------------------------------------------------------------------------------- /core/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | from django.contrib.auth.models import AbstractUser, AbstractBaseUser 3 | 4 | 5 | class CustomUser(AbstractUser): 6 | pass 7 | 8 | -------------------------------------------------------------------------------- /core/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | -------------------------------------------------------------------------------- /core/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render, reverse 2 | from django.views.generic.edit import CreateView 3 | from .forms import CustomUserCreationForm 4 | 5 | 6 | # create home page view 7 | def home(request): 8 | return render(request, 'pages/home.html') 9 | 10 | 11 | # create signup view 12 | class SignUpView(CreateView): 13 | form_class = CustomUserCreationForm 14 | template_name = 'registration/signup.html' 15 | 16 | def get_success_url(self): 17 | return reverse('login') 18 | -------------------------------------------------------------------------------- /db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hwandev12/django-authentication-app/cb3fbc50f9b1960cbd281cc7b042cddb20775961/db.sqlite3 -------------------------------------------------------------------------------- /demo/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hwandev12/django-authentication-app/cb3fbc50f9b1960cbd281cc7b042cddb20775961/demo/__init__.py -------------------------------------------------------------------------------- /demo/asgi.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from django.core.asgi import get_asgi_application 4 | 5 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'demo.settings') 6 | 7 | application = get_asgi_application() 8 | -------------------------------------------------------------------------------- /demo/settings.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | 3 | BASE_DIR = Path(__file__).resolve().parent.parent 4 | 5 | SECRET_KEY = 'django-insecure-8qp1ei(_31@&o)(z8i92g+vb+c#g_y+yikbju^7mf5-d5(9c)4' 6 | 7 | DEBUG = True 8 | 9 | ALLOWED_HOSTS = [] 10 | 11 | INSTALLED_APPS = [ 12 | 'django.contrib.admin', 13 | 'django.contrib.auth', 14 | 'django.contrib.contenttypes', 15 | 'django.contrib.sessions', 16 | 'django.contrib.messages', 17 | 'django.contrib.staticfiles', 18 | 'django.contrib.sites', 19 | 'allauth', 20 | 'allauth.account', 21 | 'allauth.socialaccount', 22 | 'allauth.socialaccount.providers.google', 23 | 'core' 24 | ] 25 | 26 | MIDDLEWARE = [ 27 | 'django.middleware.security.SecurityMiddleware', 28 | 'django.contrib.sessions.middleware.SessionMiddleware', 29 | 'django.middleware.common.CommonMiddleware', 30 | 'django.middleware.csrf.CsrfViewMiddleware', 31 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 32 | 'django.contrib.messages.middleware.MessageMiddleware', 33 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 34 | ] 35 | 36 | ROOT_URLCONF = 'demo.urls' 37 | 38 | TEMPLATES = [ 39 | { 40 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 41 | 'DIRS': [ BASE_DIR / 'frontend' ], 42 | 'APP_DIRS': True, 43 | 'OPTIONS': { 44 | 'context_processors': [ 45 | 'django.template.context_processors.debug', 46 | 'django.template.context_processors.request', 47 | 'django.contrib.auth.context_processors.auth', 48 | 'django.contrib.messages.context_processors.messages', 49 | ], 50 | }, 51 | }, 52 | ] 53 | 54 | WSGI_APPLICATION = 'demo.wsgi.application' 55 | 56 | DATABASES = { 57 | 'default': { 58 | 'ENGINE': 'django.db.backends.sqlite3', 59 | 'NAME': BASE_DIR / 'db.sqlite3', 60 | } 61 | } 62 | 63 | AUTH_PASSWORD_VALIDATORS = [ 64 | { 65 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 66 | }, 67 | { 68 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 69 | }, 70 | { 71 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 72 | }, 73 | { 74 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 75 | }, 76 | ] 77 | 78 | LOGIN_REDIRECT_URL = '/' 79 | LOGOUT_REDIRECT_URL = '/' 80 | AUTH_USER_MODEL = 'core.CustomUser' 81 | 82 | 83 | LANGUAGE_CODE = 'uz' 84 | 85 | TIME_ZONE = 'UTC' 86 | 87 | USE_I18N = True 88 | 89 | USE_TZ = True 90 | 91 | STATIC_URL = 'static/' 92 | 93 | STATICFILES_DIRS = [ 94 | BASE_DIR / "static", 95 | ] 96 | STATIC_ROOT = 'static_root' 97 | 98 | MEDIA_URL = '/media/' 99 | 100 | DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' 101 | 102 | # Allauth 103 | AUTHENTICATION_BACKENDS = [ 104 | 'django.contrib.auth.backends.ModelBackend', 105 | 'allauth.account.auth_backends.AuthenticationBackend', 106 | ] 107 | 108 | SITE_ID = 1 109 | -------------------------------------------------------------------------------- /demo/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf import settings 2 | from django.conf.urls.static import static 3 | from django.contrib import admin 4 | from django.urls import path, include 5 | from core.views import * 6 | 7 | 8 | urlpatterns = [ 9 | path('admin/', admin.site.urls), 10 | path('', home, name='home'), 11 | path('accounts/', include('allauth.urls')), 12 | path('signup/', SignUpView.as_view(), name='signup'), 13 | path('accounts/', include('django.contrib.auth.urls')) 14 | ] 15 | 16 | if settings.DEBUG: 17 | urlpatterns += static(settings.STATIC_URL, 18 | document_root=settings.STATIC_ROOT) 19 | urlpatterns += static(settings.MEDIA_URL, 20 | document_root=settings.MEDIA_ROOT) -------------------------------------------------------------------------------- /demo/wsgi.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from django.core.wsgi import get_wsgi_application 4 | 5 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'demo.settings') 6 | 7 | application = get_wsgi_application() 8 | -------------------------------------------------------------------------------- /frontend/base.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Authentication 8 | 10 | 13 | 14 | 15 | {% include 'includes/navbar.html' %} 16 |
17 | {% block content %} 18 | {% endblock content %} 19 |
20 | 23 | 26 | 27 | -------------------------------------------------------------------------------- /frontend/includes/navbar.html: -------------------------------------------------------------------------------- 1 | 2 | 127 | -------------------------------------------------------------------------------- /frontend/pages/home.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block content %} 4 |

This is a home page here

5 | {% endblock content %} -------------------------------------------------------------------------------- /frontend/registration/login.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block content %} 4 |
5 | {% csrf_token %} 6 | {{ form.as_p }} 7 | 8 |
9 | {% endblock content %} -------------------------------------------------------------------------------- /frontend/registration/signup.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block content %} 4 |
5 | {% csrf_token %} 6 | {{ form.as_p }} 7 | 8 |
9 | {% endblock content %} -------------------------------------------------------------------------------- /manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Django's command-line utility for administrative tasks.""" 3 | import os 4 | import sys 5 | 6 | 7 | def main(): 8 | """Run administrative tasks.""" 9 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'demo.settings') 10 | try: 11 | from django.core.management import execute_from_command_line 12 | except ImportError as exc: 13 | raise ImportError( 14 | "Couldn't import Django. Are you sure it's installed and " 15 | "available on your PYTHONPATH environment variable? Did you " 16 | "forget to activate a virtual environment?" 17 | ) from exc 18 | execute_from_command_line(sys.argv) 19 | 20 | 21 | if __name__ == '__main__': 22 | main() 23 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hwandev12/django-authentication-app/cb3fbc50f9b1960cbd281cc7b042cddb20775961/requirements.txt -------------------------------------------------------------------------------- /static/css/main.css: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------------- /static/js/main.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hwandev12/django-authentication-app/cb3fbc50f9b1960cbd281cc7b042cddb20775961/static/js/main.js --------------------------------------------------------------------------------