├── README.md └── elevate ├── crm ├── __init__.py ├── __pycache__ │ ├── __init__.cpython-311.pyc │ ├── admin.cpython-311.pyc │ ├── apps.cpython-311.pyc │ ├── forms.cpython-311.pyc │ ├── models.cpython-311.pyc │ ├── urls.cpython-311.pyc │ └── views.cpython-311.pyc ├── admin.py ├── apps.py ├── forms.py ├── migrations │ ├── __init__.py │ └── __pycache__ │ │ └── __init__.cpython-311.pyc ├── models.py ├── templates │ └── crm │ │ ├── dashboard.html │ │ ├── index.html │ │ ├── my-login.html │ │ └── register.html ├── tests.py ├── urls.py └── views.py ├── db.sqlite3 ├── elevate ├── __init__.py ├── __pycache__ │ ├── __init__.cpython-311.pyc │ ├── settings.cpython-311.pyc │ ├── urls.cpython-311.pyc │ └── wsgi.cpython-311.pyc ├── asgi.py ├── settings.py ├── urls.py └── wsgi.py └── manage.py /README.md: -------------------------------------------------------------------------------- 1 | # About the project 2 | 3 | A straightforward Django project showcasing user authentication with login, logout, and registration functionality. 4 | 5 | # Support 6 | 7 | If you like this project and want to leave a donation, you are more than welcome to support this project down below: 8 | 9 | [![Donate with Stripe](https://img.shields.io/badge/Donate%20with%20Stripe-6a1b9a?style=for-the-badge&logo=stripe&logoColor=white)](https://donate.stripe.com/28o4hEeFg5mcc3C9AE) 10 | 11 | # Connect 12 | 13 | Feel free to connect with me on the following platforms: 14 | 15 | [![Subscribe on YouTube](https://img.shields.io/badge/Subscribe%20on%20YouTube-ff0000?style=for-the-badge&logo=youtube&logoColor=white)](https://www.youtube.com/@CloudWithDjango) 16 | 17 | [![Follow on X](https://img.shields.io/badge/Follow%20on%20X-000000?style=for-the-badge&logo=x&logoColor=white)](https://x.com/CloudWDjango) 18 | -------------------------------------------------------------------------------- /elevate/crm/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloud-with-django/django-auth/02c760cb8be91a6cd64412925a2f1df0f9d77f5e/elevate/crm/__init__.py -------------------------------------------------------------------------------- /elevate/crm/__pycache__/__init__.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloud-with-django/django-auth/02c760cb8be91a6cd64412925a2f1df0f9d77f5e/elevate/crm/__pycache__/__init__.cpython-311.pyc -------------------------------------------------------------------------------- /elevate/crm/__pycache__/admin.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloud-with-django/django-auth/02c760cb8be91a6cd64412925a2f1df0f9d77f5e/elevate/crm/__pycache__/admin.cpython-311.pyc -------------------------------------------------------------------------------- /elevate/crm/__pycache__/apps.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloud-with-django/django-auth/02c760cb8be91a6cd64412925a2f1df0f9d77f5e/elevate/crm/__pycache__/apps.cpython-311.pyc -------------------------------------------------------------------------------- /elevate/crm/__pycache__/forms.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloud-with-django/django-auth/02c760cb8be91a6cd64412925a2f1df0f9d77f5e/elevate/crm/__pycache__/forms.cpython-311.pyc -------------------------------------------------------------------------------- /elevate/crm/__pycache__/models.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloud-with-django/django-auth/02c760cb8be91a6cd64412925a2f1df0f9d77f5e/elevate/crm/__pycache__/models.cpython-311.pyc -------------------------------------------------------------------------------- /elevate/crm/__pycache__/urls.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloud-with-django/django-auth/02c760cb8be91a6cd64412925a2f1df0f9d77f5e/elevate/crm/__pycache__/urls.cpython-311.pyc -------------------------------------------------------------------------------- /elevate/crm/__pycache__/views.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloud-with-django/django-auth/02c760cb8be91a6cd64412925a2f1df0f9d77f5e/elevate/crm/__pycache__/views.cpython-311.pyc -------------------------------------------------------------------------------- /elevate/crm/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /elevate/crm/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class CrmConfig(AppConfig): 5 | default_auto_field = 'django.db.models.BigAutoField' 6 | name = 'crm' 7 | -------------------------------------------------------------------------------- /elevate/crm/forms.py: -------------------------------------------------------------------------------- 1 | 2 | from django.contrib.auth.forms import UserCreationForm, AuthenticationForm 3 | from django.contrib.auth.models import User 4 | 5 | from django import forms 6 | 7 | from django.forms.widgets import PasswordInput, TextInput 8 | 9 | 10 | # - Create/Register a user (Model Form) 11 | 12 | class CreateUserForm(UserCreationForm): 13 | 14 | class Meta: 15 | 16 | model = User 17 | fields = ['username', 'email', 'password1', 'password2'] 18 | 19 | 20 | # - Authenticate a user (Model Form) 21 | 22 | class LoginForm(AuthenticationForm): 23 | 24 | username = forms.CharField(widget=TextInput()) 25 | password = forms.CharField(widget=PasswordInput()) 26 | -------------------------------------------------------------------------------- /elevate/crm/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloud-with-django/django-auth/02c760cb8be91a6cd64412925a2f1df0f9d77f5e/elevate/crm/migrations/__init__.py -------------------------------------------------------------------------------- /elevate/crm/migrations/__pycache__/__init__.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloud-with-django/django-auth/02c760cb8be91a6cd64412925a2f1df0f9d77f5e/elevate/crm/migrations/__pycache__/__init__.cpython-311.pyc -------------------------------------------------------------------------------- /elevate/crm/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | -------------------------------------------------------------------------------- /elevate/crm/templates/crm/dashboard.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |

This is my dashboard.

4 | 5 | Logout here 6 | 7 | -------------------------------------------------------------------------------- /elevate/crm/templates/crm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |

This is the homepage

4 | 5 | Register here 6 | 7 |

8 | 9 | Login here 10 | 11 | -------------------------------------------------------------------------------- /elevate/crm/templates/crm/my-login.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Login here

4 | 5 |
6 | 7 | {% csrf_token %} 8 | 9 | {{loginform.as_p}} 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /elevate/crm/templates/crm/register.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Register now!

4 | 5 |
6 | 7 | {% csrf_token %} 8 | 9 | {{registerform.as_p}} 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /elevate/crm/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /elevate/crm/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import path 2 | 3 | from . import views 4 | 5 | urlpatterns = [ 6 | 7 | path('', views.homepage, name=""), 8 | 9 | path('register', views.register, name="register"), 10 | 11 | path('my-login', views.my_login, name="my-login"), 12 | 13 | path('dashboard', views.dashboard, name="dashboard"), 14 | 15 | path('user-logout', views.user_logout, name="user-logout"), 16 | 17 | ] 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /elevate/crm/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render, redirect 2 | 3 | from . forms import CreateUserForm, LoginForm 4 | 5 | from django.contrib.auth.decorators import login_required 6 | 7 | 8 | # - Authentication models and functions 9 | 10 | from django.contrib.auth.models import auth 11 | from django.contrib.auth import authenticate, login, logout 12 | 13 | 14 | def homepage(request): 15 | 16 | return render(request, 'crm/index.html') 17 | 18 | 19 | 20 | 21 | def register(request): 22 | 23 | form = CreateUserForm() 24 | 25 | if request.method == "POST": 26 | 27 | form = CreateUserForm(request.POST) 28 | 29 | if form.is_valid(): 30 | 31 | form.save() 32 | 33 | return redirect("my-login") 34 | 35 | 36 | context = {'registerform':form} 37 | 38 | return render(request, 'crm/register.html', context=context) 39 | 40 | 41 | 42 | def my_login(request): 43 | 44 | form = LoginForm() 45 | 46 | if request.method == 'POST': 47 | 48 | form = LoginForm(request, data=request.POST) 49 | 50 | if form.is_valid(): 51 | 52 | username = request.POST.get('username') 53 | password = request.POST.get('password') 54 | 55 | user = authenticate(request, username=username, password=password) 56 | 57 | if user is not None: 58 | 59 | auth.login(request, user) 60 | 61 | return redirect("dashboard") 62 | 63 | 64 | context = {'loginform':form} 65 | 66 | return render(request, 'crm/my-login.html', context=context) 67 | 68 | 69 | def user_logout(request): 70 | 71 | auth.logout(request) 72 | 73 | return redirect("") 74 | 75 | 76 | 77 | @login_required(login_url="my-login") 78 | def dashboard(request): 79 | 80 | return render(request, 'crm/dashboard.html') 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /elevate/db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloud-with-django/django-auth/02c760cb8be91a6cd64412925a2f1df0f9d77f5e/elevate/db.sqlite3 -------------------------------------------------------------------------------- /elevate/elevate/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloud-with-django/django-auth/02c760cb8be91a6cd64412925a2f1df0f9d77f5e/elevate/elevate/__init__.py -------------------------------------------------------------------------------- /elevate/elevate/__pycache__/__init__.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloud-with-django/django-auth/02c760cb8be91a6cd64412925a2f1df0f9d77f5e/elevate/elevate/__pycache__/__init__.cpython-311.pyc -------------------------------------------------------------------------------- /elevate/elevate/__pycache__/settings.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloud-with-django/django-auth/02c760cb8be91a6cd64412925a2f1df0f9d77f5e/elevate/elevate/__pycache__/settings.cpython-311.pyc -------------------------------------------------------------------------------- /elevate/elevate/__pycache__/urls.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloud-with-django/django-auth/02c760cb8be91a6cd64412925a2f1df0f9d77f5e/elevate/elevate/__pycache__/urls.cpython-311.pyc -------------------------------------------------------------------------------- /elevate/elevate/__pycache__/wsgi.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloud-with-django/django-auth/02c760cb8be91a6cd64412925a2f1df0f9d77f5e/elevate/elevate/__pycache__/wsgi.cpython-311.pyc -------------------------------------------------------------------------------- /elevate/elevate/asgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | ASGI config for elevate project. 3 | 4 | It exposes the ASGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.asgi import get_asgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'elevate.settings') 15 | 16 | application = get_asgi_application() 17 | -------------------------------------------------------------------------------- /elevate/elevate/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for elevate project. 3 | 4 | Generated by 'django-admin startproject' using Django 4.2.3. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/4.2/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/4.2/ref/settings/ 11 | """ 12 | 13 | from pathlib import Path 14 | 15 | # Build paths inside the project like this: BASE_DIR / 'subdir'. 16 | BASE_DIR = Path(__file__).resolve().parent.parent 17 | 18 | 19 | # Quick-start development settings - unsuitable for production 20 | # See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/ 21 | 22 | # SECURITY WARNING: keep the secret key used in production secret! 23 | SECRET_KEY = 'django-insecure-n2n*fl6c314w3=_y=i(_@%#lqin1)h*gcosu_q=#yab7dg3wep' 24 | 25 | # SECURITY WARNING: don't run with debug turned on in production! 26 | DEBUG = True 27 | 28 | ALLOWED_HOSTS = [] 29 | 30 | 31 | # Application definition 32 | 33 | INSTALLED_APPS = [ 34 | 'django.contrib.admin', 35 | 'django.contrib.auth', 36 | 'django.contrib.contenttypes', 37 | 'django.contrib.sessions', 38 | 'django.contrib.messages', 39 | 'django.contrib.staticfiles', 40 | 41 | 'crm', 42 | ] 43 | 44 | MIDDLEWARE = [ 45 | 'django.middleware.security.SecurityMiddleware', 46 | 'django.contrib.sessions.middleware.SessionMiddleware', 47 | 'django.middleware.common.CommonMiddleware', 48 | 'django.middleware.csrf.CsrfViewMiddleware', 49 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 50 | 'django.contrib.messages.middleware.MessageMiddleware', 51 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 52 | ] 53 | 54 | ROOT_URLCONF = 'elevate.urls' 55 | 56 | TEMPLATES = [ 57 | { 58 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 59 | 'DIRS': [], 60 | 'APP_DIRS': True, 61 | 'OPTIONS': { 62 | 'context_processors': [ 63 | 'django.template.context_processors.debug', 64 | 'django.template.context_processors.request', 65 | 'django.contrib.auth.context_processors.auth', 66 | 'django.contrib.messages.context_processors.messages', 67 | ], 68 | }, 69 | }, 70 | ] 71 | 72 | WSGI_APPLICATION = 'elevate.wsgi.application' 73 | 74 | 75 | # Database 76 | # https://docs.djangoproject.com/en/4.2/ref/settings/#databases 77 | 78 | DATABASES = { 79 | 'default': { 80 | 'ENGINE': 'django.db.backends.sqlite3', 81 | 'NAME': BASE_DIR / 'db.sqlite3', 82 | } 83 | } 84 | 85 | 86 | # Password validation 87 | # https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators 88 | 89 | AUTH_PASSWORD_VALIDATORS = [ 90 | { 91 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 92 | }, 93 | { 94 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 95 | }, 96 | { 97 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 98 | }, 99 | { 100 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 101 | }, 102 | ] 103 | 104 | 105 | # Internationalization 106 | # https://docs.djangoproject.com/en/4.2/topics/i18n/ 107 | 108 | LANGUAGE_CODE = 'en-us' 109 | 110 | TIME_ZONE = 'UTC' 111 | 112 | USE_I18N = True 113 | 114 | USE_TZ = True 115 | 116 | 117 | # Static files (CSS, JavaScript, Images) 118 | # https://docs.djangoproject.com/en/4.2/howto/static-files/ 119 | 120 | STATIC_URL = 'static/' 121 | 122 | # Default primary key field type 123 | # https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field 124 | 125 | DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' 126 | -------------------------------------------------------------------------------- /elevate/elevate/urls.py: -------------------------------------------------------------------------------- 1 | 2 | from django.contrib import admin 3 | from django.urls import path, include 4 | 5 | urlpatterns = [ 6 | path('admin/', admin.site.urls), 7 | 8 | path('', include('crm.urls')), 9 | ] 10 | -------------------------------------------------------------------------------- /elevate/elevate/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for elevate project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'elevate.settings') 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /elevate/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', 'elevate.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 | --------------------------------------------------------------------------------