├── .gitignore
├── README.md
└── loginSignup
├── base
├── __init__.py
├── admin.py
├── apps.py
├── migrations
│ └── __init__.py
├── models.py
├── static
│ └── css
│ │ └── style.css
├── templates
│ ├── base.html
│ ├── home.html
│ └── registration
│ │ ├── login.html
│ │ └── signup.html
├── tests.py
├── urls.py
└── views.py
├── loginSignup
├── __init__.py
├── asgi.py
├── settings.py
├── urls.py
└── wsgi.py
└── manage.py
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | build/
12 | develop-eggs/
13 | dist/
14 | downloads/
15 | eggs/
16 | .eggs/
17 | lib/
18 | lib64/
19 | parts/
20 | sdist/
21 | var/
22 | wheels/
23 | share/python-wheels/
24 | *.egg-info/
25 | .installed.cfg
26 | *.egg
27 | MANIFEST
28 |
29 | # PyInstaller
30 | # Usually these files are written by a python script from a template
31 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
32 | *.manifest
33 | *.spec
34 |
35 | # Installer logs
36 | pip-log.txt
37 | pip-delete-this-directory.txt
38 |
39 | # Unit test / coverage reports
40 | htmlcov/
41 | .tox/
42 | .nox/
43 | .coverage
44 | .coverage.*
45 | .cache
46 | nosetests.xml
47 | coverage.xml
48 | *.cover
49 | *.py,cover
50 | .hypothesis/
51 | .pytest_cache/
52 | cover/
53 |
54 | # Translations
55 | *.mo
56 | *.pot
57 |
58 | # Django stuff:
59 | *.log
60 | local_settings.py
61 | db.sqlite3
62 | db.sqlite3-journal
63 |
64 | # Flask stuff:
65 | instance/
66 | .webassets-cache
67 |
68 | # Scrapy stuff:
69 | .scrapy
70 |
71 | # Sphinx documentation
72 | docs/_build/
73 |
74 | # PyBuilder
75 | .pybuilder/
76 | target/
77 |
78 | # Jupyter Notebook
79 | .ipynb_checkpoints
80 |
81 | # IPython
82 | profile_default/
83 | ipython_config.py
84 |
85 | # pyenv
86 | # For a library or package, you might want to ignore these files since the code is
87 | # intended to run in multiple environments; otherwise, check them in:
88 | # .python-version
89 |
90 | # pipenv
91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not
94 | # install all needed dependencies.
95 | #Pipfile.lock
96 |
97 | # poetry
98 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99 | # This is especially recommended for binary packages to ensure reproducibility, and is more
100 | # commonly ignored for libraries.
101 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102 | #poetry.lock
103 |
104 | # pdm
105 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106 | #pdm.lock
107 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108 | # in version control.
109 | # https://pdm.fming.dev/#use-with-ide
110 | .pdm.toml
111 |
112 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113 | __pypackages__/
114 |
115 | # Celery stuff
116 | celerybeat-schedule
117 | celerybeat.pid
118 |
119 | # SageMath parsed files
120 | *.sage.py
121 |
122 | # Environments
123 | .env
124 | .venv
125 | env/
126 | venv/
127 | ENV/
128 | env.bak/
129 | venv.bak/
130 |
131 | # Spyder project settings
132 | .spyderproject
133 | .spyproject
134 |
135 | # Rope project settings
136 | .ropeproject
137 |
138 | # mkdocs documentation
139 | /site
140 |
141 | # mypy
142 | .mypy_cache/
143 | .dmypy.json
144 | dmypy.json
145 |
146 | # Pyre type checker
147 | .pyre/
148 |
149 | # pytype static type analyzer
150 | .pytype/
151 |
152 | # Cython debug symbols
153 | cython_debug/
154 |
155 | # PyCharm
156 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158 | # and can be added to the global gitignore or merged into this file. For a more nuclear
159 | # option (not recommended) you can uncomment the following to ignore the entire idea folder.
160 | #.idea/
161 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Complete Auth flow explanation for django project.
2 |
3 | Star it for future.
4 |
5 |
6 | Youtube Video
7 | https://www.youtube.com/watch?v=OojA7SPViEs
8 |
--------------------------------------------------------------------------------
/loginSignup/base/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yeole-rohan/User-Authentication-and-User-Signup-in-Python-using-Django-/7c28a30845a02ae588de734902ca7ab821dd6f71/loginSignup/base/__init__.py
--------------------------------------------------------------------------------
/loginSignup/base/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 |
3 | # Register your models here.
4 |
--------------------------------------------------------------------------------
/loginSignup/base/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class BaseConfig(AppConfig):
5 | default_auto_field = 'django.db.models.BigAutoField'
6 | name = 'base'
7 |
--------------------------------------------------------------------------------
/loginSignup/base/migrations/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yeole-rohan/User-Authentication-and-User-Signup-in-Python-using-Django-/7c28a30845a02ae588de734902ca7ab821dd6f71/loginSignup/base/migrations/__init__.py
--------------------------------------------------------------------------------
/loginSignup/base/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 |
3 | # Create your models here.
4 |
--------------------------------------------------------------------------------
/loginSignup/base/static/css/style.css:
--------------------------------------------------------------------------------
1 | *{
2 | padding: 0;
3 | margin: 0;
4 | box-sizing: border-box;
5 | font-family: 'Mulish', sans-serif;
6 | transition: 0.3s all ease-in-out;
7 | }
8 | body{
9 | display: flex;
10 | justify-content: center;
11 | align-items: center;
12 | height: 100vh;
13 | background-color: #fff;
14 | }
15 | .shadow-wrap{
16 | border-radius: 5px;
17 | padding: 25px;
18 | background-color:#F0F2FB;
19 | }
20 | .form-wrap{
21 | background-color: #fff;
22 | padding: 70px;
23 | }
24 | .form-wrap form *{
25 | display: block;
26 | width: 100%;
27 | }
28 | .form-wrap form label{
29 | margin-bottom: 5px;
30 | font-size: 14px;
31 | font-weight: 700;
32 | line-height: 26px;
33 | }
34 | .form-wrap form input{
35 | padding: 12px 20px;
36 | border-radius: 5px;
37 | border: 1px solid #DAE1F5;
38 | background: #FFF;
39 | color: #545D7A;
40 | }
41 | #id_username{
42 | margin-bottom: 20px;
43 | }
44 | .form-wrap button{
45 | border-radius: 5px;
46 | background: #10182F;
47 | color: #FFF;
48 | cursor: pointer;
49 | text-align: center;
50 | font-size: 16px;
51 | padding: 12px 68px;
52 | font-weight: 700;
53 | border: 1px solid transparent;
54 | margin-top: 30px;
55 | line-height: 26px;
56 | }
57 | .signup-link{
58 | color: #10182F;
59 | font-size: 15px;
60 | margin-top: 20px;
61 | text-align: center;
62 | line-height: 25px;
63 | display: block;
64 | text-decoration: none;
65 | }
66 | .signup-link:hover{
67 | text-decoration: underline;
68 | }
69 | .form-wrap button:hover{
70 | background-color: #fff;
71 | color: #10182F;
72 | border-color: #10182F;
73 |
74 | }
--------------------------------------------------------------------------------
/loginSignup/base/templates/base.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Login Registration Demo
7 |
8 |
9 |
10 | {% load static %}
11 |
12 |
13 |
14 | {% block content %}{% endblock content %}
15 |
16 |
--------------------------------------------------------------------------------
/loginSignup/base/templates/home.html:
--------------------------------------------------------------------------------
1 | {% extends "base.html" %}
2 | {% block content %}
3 | home page
4 | logout
5 | {% endblock content %}
--------------------------------------------------------------------------------
/loginSignup/base/templates/registration/login.html:
--------------------------------------------------------------------------------
1 | {% extends "base.html" %}
2 | {% block content %}
3 |
14 | {% endblock content %}a
15 |
--------------------------------------------------------------------------------
/loginSignup/base/templates/registration/signup.html:
--------------------------------------------------------------------------------
1 | {% extends "base.html" %}
2 | {% block content %}
3 |
14 | {% endblock content %}a
15 |
--------------------------------------------------------------------------------
/loginSignup/base/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/loginSignup/base/urls.py:
--------------------------------------------------------------------------------
1 | from django.urls import path, include
2 | from .views import authView, home
3 |
4 | urlpatterns = [
5 | path("", home, name="home"),
6 | path("signup/", authView, name="authView"),
7 | path("accounts/", include("django.contrib.auth.urls")),
8 | ]
9 |
--------------------------------------------------------------------------------
/loginSignup/base/views.py:
--------------------------------------------------------------------------------
1 | from django.shortcuts import render, redirect
2 | from django.contrib.auth.forms import UserCreationForm
3 | from django.contrib.auth.decorators import login_required
4 |
5 |
6 | @login_required
7 | def home(request):
8 | return render(request, "home.html", {})
9 |
10 |
11 | def authView(request):
12 | if request.method == "POST":
13 | form = UserCreationForm(request.POST or None)
14 | if form.is_valid():
15 | form.save()
16 | return redirect("base:login")
17 | else:
18 | form = UserCreationForm()
19 | return render(request, "registration/signup.html", {"form": form})
20 |
--------------------------------------------------------------------------------
/loginSignup/loginSignup/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yeole-rohan/User-Authentication-and-User-Signup-in-Python-using-Django-/7c28a30845a02ae588de734902ca7ab821dd6f71/loginSignup/loginSignup/__init__.py
--------------------------------------------------------------------------------
/loginSignup/loginSignup/asgi.py:
--------------------------------------------------------------------------------
1 | """
2 | ASGI config for loginSignup 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', 'loginSignup.settings')
15 |
16 | application = get_asgi_application()
17 |
--------------------------------------------------------------------------------
/loginSignup/loginSignup/settings.py:
--------------------------------------------------------------------------------
1 | """
2 | Django settings for loginSignup project.
3 |
4 | Generated by 'django-admin startproject' using Django 4.2.8.
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-ro!4($icx-m@sihzsvue1&sn=@6on708ue((kx1^(0c4mqjr+l'
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 | 'base',
41 | ]
42 |
43 | MIDDLEWARE = [
44 | 'django.middleware.security.SecurityMiddleware',
45 | 'django.contrib.sessions.middleware.SessionMiddleware',
46 | 'django.middleware.common.CommonMiddleware',
47 | 'django.middleware.csrf.CsrfViewMiddleware',
48 | 'django.contrib.auth.middleware.AuthenticationMiddleware',
49 | 'django.contrib.messages.middleware.MessageMiddleware',
50 | 'django.middleware.clickjacking.XFrameOptionsMiddleware',
51 | ]
52 |
53 | ROOT_URLCONF = 'loginSignup.urls'
54 |
55 | TEMPLATES = [
56 | {
57 | 'BACKEND': 'django.template.backends.django.DjangoTemplates',
58 | 'DIRS': [BASE_DIR / "templates"],
59 | 'APP_DIRS': True,
60 | 'OPTIONS': {
61 | 'context_processors': [
62 | 'django.template.context_processors.debug',
63 | 'django.template.context_processors.request',
64 | 'django.contrib.auth.context_processors.auth',
65 | 'django.contrib.messages.context_processors.messages',
66 | ],
67 | },
68 | },
69 | ]
70 |
71 | WSGI_APPLICATION = 'loginSignup.wsgi.application'
72 |
73 |
74 | # Database
75 | # https://docs.djangoproject.com/en/4.2/ref/settings/#databases
76 |
77 | DATABASES = {
78 | 'default': {
79 | 'ENGINE': 'django.db.backends.sqlite3',
80 | 'NAME': BASE_DIR / 'db.sqlite3',
81 | }
82 | }
83 |
84 |
85 | # Password validation
86 | # https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
87 |
88 | AUTH_PASSWORD_VALIDATORS = [
89 | {
90 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
91 | },
92 | {
93 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
94 | },
95 | {
96 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
97 | },
98 | {
99 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
100 | },
101 | ]
102 |
103 |
104 | # Internationalization
105 | # https://docs.djangoproject.com/en/4.2/topics/i18n/
106 |
107 | LANGUAGE_CODE = 'en-us'
108 |
109 | TIME_ZONE = 'UTC'
110 |
111 | USE_I18N = True
112 |
113 | USE_TZ = True
114 |
115 |
116 | # Static files (CSS, JavaScript, Images)
117 | # https://docs.djangoproject.com/en/4.2/howto/static-files/
118 |
119 | STATIC_URL = 'static/'
120 |
121 | # Default primary key field type
122 | # https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
123 |
124 | DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
125 |
126 |
127 | LOGIN_REDIRECT_URL = "base:home"
128 | LOGOUT_REDIRECT_URL = "base:login"
129 |
--------------------------------------------------------------------------------
/loginSignup/loginSignup/urls.py:
--------------------------------------------------------------------------------
1 | """
2 | URL configuration for loginSignup project.
3 |
4 | The `urlpatterns` list routes URLs to views. For more information please see:
5 | https://docs.djangoproject.com/en/4.2/topics/http/urls/
6 | Examples:
7 | Function views
8 | 1. Add an import: from my_app import views
9 | 2. Add a URL to urlpatterns: path('', views.home, name='home')
10 | Class-based views
11 | 1. Add an import: from other_app.views import Home
12 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
13 | Including another URLconf
14 | 1. Import the include() function: from django.urls import include, path
15 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
16 | """
17 | from django.contrib import admin
18 | from django.urls import path, include
19 | from django.conf import settings
20 | from django.conf.urls.static import static
21 |
22 | urlpatterns = [
23 | path('admin/', admin.site.urls),
24 | path("", include(("base.urls", "base"), "base"))
25 | ] + static(settings.STATIC_URL)
26 |
--------------------------------------------------------------------------------
/loginSignup/loginSignup/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for loginSignup 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', 'loginSignup.settings')
15 |
16 | application = get_wsgi_application()
17 |
--------------------------------------------------------------------------------
/loginSignup/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', 'loginSignup.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 |
--------------------------------------------------------------------------------