├── .gitpod.yml ├── README.md ├── mysite ├── __pycache__ │ └── manage.cpython-36.pyc ├── db.sqlite3 ├── main │ ├── __pycache__ │ │ ├── __init__.cpython-36.pyc │ │ ├── __init__.cpython-37.pyc │ │ ├── admin.cpython-36.pyc │ │ ├── admin.cpython-37.pyc │ │ ├── apps.cpython-36.pyc │ │ ├── apps.cpython-37.pyc │ │ ├── forms.cpython-36.pyc │ │ ├── forms.cpython-37.pyc │ │ ├── models.cpython-36.pyc │ │ ├── models.cpython-37.pyc │ │ ├── urls.cpython-36.pyc │ │ ├── urls.cpython-37.pyc │ │ ├── views.cpython-36.pyc │ │ └── views.cpython-37.pyc │ ├── admin.py │ ├── apps.py │ ├── forms.py │ ├── migrations │ │ ├── 0001_initial.py │ │ └── __pycache__ │ │ │ ├── 0001_initial.cpython-36.pyc │ │ │ ├── 0001_initial.cpython-37.pyc │ │ │ ├── __init__.cpython-36.pyc │ │ │ └── __init__.cpython-37.pyc │ ├── models.py │ ├── templates │ │ └── main │ │ │ ├── base.html │ │ │ ├── create.html │ │ │ ├── home.html │ │ │ ├── index.html │ │ │ └── view.html │ ├── tests.py │ ├── urls.py │ └── views.py ├── manage.py ├── mysite │ ├── __pycache__ │ │ ├── __init__.cpython-36.pyc │ │ ├── __init__.cpython-37.pyc │ │ ├── settings.cpython-36.pyc │ │ ├── settings.cpython-37.pyc │ │ ├── urls.cpython-36.pyc │ │ ├── urls.cpython-37.pyc │ │ ├── wsgi.cpython-36.pyc │ │ └── wsgi.cpython-37.pyc │ ├── settings.py │ ├── urls.py │ └── wsgi.py └── register │ ├── __pycache__ │ ├── __init__.cpython-36.pyc │ ├── __init__.cpython-37.pyc │ ├── admin.cpython-36.pyc │ ├── admin.cpython-37.pyc │ ├── apps.cpython-36.pyc │ ├── apps.cpython-37.pyc │ ├── forms.cpython-36.pyc │ ├── forms.cpython-37.pyc │ ├── models.cpython-36.pyc │ ├── models.cpython-37.pyc │ ├── views.cpython-36.pyc │ └── views.cpython-37.pyc │ ├── admin.py │ ├── apps.py │ ├── forms.py │ ├── migrations │ ├── 0001_initial.py │ └── __pycache__ │ │ ├── 0001_initial.cpython-36.pyc │ │ ├── 0001_initial.cpython-37.pyc │ │ ├── __init__.cpython-36.pyc │ │ └── __init__.cpython-37.pyc │ ├── models.py │ ├── templates │ ├── register │ │ └── register.html │ └── registration │ │ └── login.html │ ├── tests.py │ └── views.py └── requirements.txt /.gitpod.yml: -------------------------------------------------------------------------------- 1 | ports: 2 | - port: 8080 3 | onOpen: open-preview 4 | tasks: 5 | - init: > 6 | python3 -m pip install -r requirements.txt && 7 | cd mysite && 8 | python3 manage.py migrate 9 | command: > 10 | echo "from mysite.settings import *" > mysite/local_settings.py && 11 | echo "ALLOWED_HOSTS = ['*']" >> mysite/local_settings.py && 12 | export DJANGO_SETTINGS_MODULE=mysite.local_settings && 13 | python3 manage.py runserver 0.0.0.0:8080 14 | github: 15 | prebuilds: 16 | pullRequestsFromForks: true -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Django-Website 2 | A very minimal website I built while learning Django. 3 | 4 | # Run The Website 5 | This website requires a few python packages: 6 | - django 7 | - django-crispy-forms 8 | 9 | To run the website navigate to upper level "mysite" directory and run the command via cmd: *python manage.py runserver* 10 | Then you should see a local host link that you can copy into your browser to see the website. 11 | 12 | # Video Tutorials 13 | You can watch these video tutorials to learn how to use django: https://www.youtube.com/watch?v=Z4D3M-NSN58&list=PLzMcBGfZo4-kQkZp-j9PNyKq7Yw5VYjq9 14 | 15 | # 💻 Launch Your Software Development Career Today! 16 | 17 | 🎓 **No degree? No problem!** My program equips you with everything you need to break into tech and land an entry-level software development role. 18 | 19 | 🚀 **Why Join?** 20 | - 💼 **$70k+ starting salary potential** 21 | - 🕐 **Self-paced:** Complete on your own time 22 | - 🤑 **Affordable:** Low risk compared to expensive bootcamps or degrees 23 | - 🎯 **45,000+ job openings** in the market 24 | 25 | 👉 **[Start your journey today!](https://techwithtim.net/dev)** 26 | No experience needed—just your determination. Future-proof your career and unlock six-figure potential like many of our students have! 27 | -------------------------------------------------------------------------------- /mysite/__pycache__/manage.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/__pycache__/manage.cpython-36.pyc -------------------------------------------------------------------------------- /mysite/db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/db.sqlite3 -------------------------------------------------------------------------------- /mysite/main/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/main/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mysite/main/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/main/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /mysite/main/__pycache__/admin.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/main/__pycache__/admin.cpython-36.pyc -------------------------------------------------------------------------------- /mysite/main/__pycache__/admin.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/main/__pycache__/admin.cpython-37.pyc -------------------------------------------------------------------------------- /mysite/main/__pycache__/apps.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/main/__pycache__/apps.cpython-36.pyc -------------------------------------------------------------------------------- /mysite/main/__pycache__/apps.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/main/__pycache__/apps.cpython-37.pyc -------------------------------------------------------------------------------- /mysite/main/__pycache__/forms.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/main/__pycache__/forms.cpython-36.pyc -------------------------------------------------------------------------------- /mysite/main/__pycache__/forms.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/main/__pycache__/forms.cpython-37.pyc -------------------------------------------------------------------------------- /mysite/main/__pycache__/models.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/main/__pycache__/models.cpython-36.pyc -------------------------------------------------------------------------------- /mysite/main/__pycache__/models.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/main/__pycache__/models.cpython-37.pyc -------------------------------------------------------------------------------- /mysite/main/__pycache__/urls.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/main/__pycache__/urls.cpython-36.pyc -------------------------------------------------------------------------------- /mysite/main/__pycache__/urls.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/main/__pycache__/urls.cpython-37.pyc -------------------------------------------------------------------------------- /mysite/main/__pycache__/views.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/main/__pycache__/views.cpython-36.pyc -------------------------------------------------------------------------------- /mysite/main/__pycache__/views.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/main/__pycache__/views.cpython-37.pyc -------------------------------------------------------------------------------- /mysite/main/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from .models import ToDoList 3 | # Register your models here. 4 | admin.site.register(ToDoList) -------------------------------------------------------------------------------- /mysite/main/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class MainConfig(AppConfig): 5 | name = 'main' 6 | -------------------------------------------------------------------------------- /mysite/main/forms.py: -------------------------------------------------------------------------------- 1 | from django import forms 2 | 3 | class CreateListForm(forms.Form): 4 | name = forms.CharField(label="Name ", max_length=300) 5 | 6 | -------------------------------------------------------------------------------- /mysite/main/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.2 on 2019-04-29 15:20 2 | 3 | from django.db import migrations, models 4 | import django.db.models.deletion 5 | 6 | 7 | class Migration(migrations.Migration): 8 | 9 | initial = True 10 | 11 | dependencies = [ 12 | ] 13 | 14 | operations = [ 15 | migrations.CreateModel( 16 | name='ToDoList', 17 | fields=[ 18 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 19 | ('date', models.DateTimeField(verbose_name='date published')), 20 | ('name', models.CharField(max_length=200)), 21 | ], 22 | ), 23 | migrations.CreateModel( 24 | name='Item', 25 | fields=[ 26 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 27 | ('text', models.CharField(max_length=500)), 28 | ('complete', models.BooleanField()), 29 | ('toDoList', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='main.ToDoList')), 30 | ], 31 | ), 32 | ] 33 | -------------------------------------------------------------------------------- /mysite/main/migrations/__pycache__/0001_initial.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/main/migrations/__pycache__/0001_initial.cpython-36.pyc -------------------------------------------------------------------------------- /mysite/main/migrations/__pycache__/0001_initial.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/main/migrations/__pycache__/0001_initial.cpython-37.pyc -------------------------------------------------------------------------------- /mysite/main/migrations/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/main/migrations/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mysite/main/migrations/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/main/migrations/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /mysite/main/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | class ToDoList(models.Model): 5 | date = models.DateTimeField("date published") 6 | name = models.CharField(max_length=200) 7 | 8 | def __str__(self): 9 | return self.name 10 | 11 | 12 | class Item(models.Model): 13 | text = models.CharField(max_length=500) 14 | toDoList = models.ForeignKey(ToDoList, on_delete=models.CASCADE) 15 | complete = models.BooleanField() 16 | 17 | def __str__(self): 18 | return self.text -------------------------------------------------------------------------------- /mysite/main/templates/main/base.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 44 | 45 | 46 | {% block title %}Tim's Site{% endblock %} 47 | 48 | 49 | 50 | 51 |
52 | Home 53 | View 54 | Create 55 |
56 | 57 | 58 |
59 |
60 |
61 |

Tech With Tim

62 |
63 | {% block content %} 64 | {% endblock %} 65 |
66 |
67 |
68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /mysite/main/templates/main/create.html: -------------------------------------------------------------------------------- 1 | {% extends 'main/base.html' %} 2 | {% block title %} 3 | Create New List 4 | {% endblock %} 5 | 6 | {% block content %} 7 |

Create a New To Do List

8 |
9 |
10 | {% csrf_token %} 11 |
12 |
13 | 14 |
15 | {{form.name}} 16 |
17 |
18 | {% endblock %} -------------------------------------------------------------------------------- /mysite/main/templates/main/home.html: -------------------------------------------------------------------------------- 1 | {% extends 'main/base.html' %} 2 | {% block title %} 3 | Home 4 | {% endblock %} 5 | 6 | 7 | {% block content %} 8 |

Home Page

9 | {% endblock %} -------------------------------------------------------------------------------- /mysite/main/templates/main/index.html: -------------------------------------------------------------------------------- 1 | {% extends 'main/base.html' %} 2 | 3 | {% block title %}View List{% endblock %} 4 | 5 | {% block content %} 6 |

{{ls.name}}

7 |
8 | {% csrf_token %} 9 | 10 | {% for item in ls.item_set.all%} 11 |
12 |
13 |
14 | 15 |
16 |
17 | 18 |
19 | {% endfor %} 20 | 21 |
22 |
23 | 24 |
25 | 26 | 27 |
28 |
29 | 30 |
31 | {% endblock %} -------------------------------------------------------------------------------- /mysite/main/templates/main/view.html: -------------------------------------------------------------------------------- 1 | {% extends 'main/base.html' %} 2 | 3 | {% block title %}View All Lists{% endblock %} 4 | 5 | 6 | {% block content %} 7 | {% if user.is_authenticated %} 8 | 13 | {% else %} 14 |

Login Here

15 | {% endif %} 16 | {% endblock %} -------------------------------------------------------------------------------- /mysite/main/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /mysite/main/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import path 2 | 3 | from . import views 4 | 5 | urlpatterns = [ 6 | path("", views.home, name="home"), 7 | path("view/", views.view, name="index"), 8 | path("home/", views.home, name="home"), 9 | path("create/", views.get_name, name="index"), 10 | path("", views.index, name="index"), 11 | ] 12 | -------------------------------------------------------------------------------- /mysite/main/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render, get_object_or_404 2 | from django.http import HttpResponse, HttpResponseRedirect 3 | from django.utils import timezone 4 | from .models import ToDoList 5 | from .forms import CreateListForm 6 | # Create your views here. 7 | 8 | def index(request, id): 9 | ls = ToDoList.objects.get(id=id) 10 | 11 | if request.method == "POST": 12 | if request.POST.get("save"): 13 | for item in ls.item_set.all(): 14 | p = request.POST 15 | 16 | if "clicked" == p.get("c"+str(item.id)): 17 | item.complete = True 18 | else: 19 | item.complete = False 20 | 21 | if "text" + str(item.id) in p: 22 | item.text = p.get("text" + str(item.id)) 23 | 24 | 25 | item.save() 26 | 27 | elif request.POST.get("add"): 28 | newItem = request.POST.get("new") 29 | if newItem != "": 30 | ls.item_set.create(text=newItem, complete=False) 31 | else: 32 | print("invalid") 33 | 34 | return render(request, "main/index.html", {"ls": ls}) 35 | 36 | 37 | def get_name(request): 38 | if request.method == "POST": 39 | form = CreateListForm(request.POST) 40 | 41 | if form.is_valid(): 42 | n = form.cleaned_data["name"] 43 | t = ToDoList(name=n, date=timezone.now()) 44 | t.save() 45 | 46 | return HttpResponseRedirect("/%i" %t.id) 47 | 48 | else: 49 | form = CreateListForm() 50 | 51 | return render(request, "main/create.html", {"form": form}) 52 | 53 | 54 | def home(request): 55 | return render(request, "main/home.html", {}) 56 | 57 | 58 | def view(request): 59 | l = ToDoList.objects.all() 60 | return render(request, "main/view.html", {"lists":l}) 61 | -------------------------------------------------------------------------------- /mysite/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 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings') 9 | try: 10 | from django.core.management import execute_from_command_line 11 | except ImportError as exc: 12 | raise ImportError( 13 | "Couldn't import Django. Are you sure it's installed and " 14 | "available on your PYTHONPATH environment variable? Did you " 15 | "forget to activate a virtual environment?" 16 | ) from exc 17 | execute_from_command_line(sys.argv) 18 | 19 | 20 | if __name__ == '__main__': 21 | main() 22 | -------------------------------------------------------------------------------- /mysite/mysite/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/mysite/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mysite/mysite/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/mysite/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /mysite/mysite/__pycache__/settings.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/mysite/__pycache__/settings.cpython-36.pyc -------------------------------------------------------------------------------- /mysite/mysite/__pycache__/settings.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/mysite/__pycache__/settings.cpython-37.pyc -------------------------------------------------------------------------------- /mysite/mysite/__pycache__/urls.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/mysite/__pycache__/urls.cpython-36.pyc -------------------------------------------------------------------------------- /mysite/mysite/__pycache__/urls.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/mysite/__pycache__/urls.cpython-37.pyc -------------------------------------------------------------------------------- /mysite/mysite/__pycache__/wsgi.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/mysite/__pycache__/wsgi.cpython-36.pyc -------------------------------------------------------------------------------- /mysite/mysite/__pycache__/wsgi.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/mysite/__pycache__/wsgi.cpython-37.pyc -------------------------------------------------------------------------------- /mysite/mysite/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for mysite project. 3 | 4 | Generated by 'django-admin startproject' using Django 2.2. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.2/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/2.2/ref/settings/ 11 | """ 12 | 13 | import os 14 | 15 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) 16 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 17 | 18 | 19 | # Quick-start development settings - unsuitable for production 20 | # See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/ 21 | 22 | # SECURITY WARNING: keep the secret key used in production secret! 23 | SECRET_KEY = 'whwxt!eumty^!72grh6kw1=i=pyx#81khts$#==op=%n((b#3x' 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 | 'main.apps.MainConfig', 41 | "register.apps.RegisterConfig", 42 | "crispy_forms", 43 | ] 44 | 45 | AUTH_USER_MODEL = "register.CustomUser" 46 | 47 | MIDDLEWARE = [ 48 | 'django.middleware.security.SecurityMiddleware', 49 | 'django.contrib.sessions.middleware.SessionMiddleware', 50 | 'django.middleware.common.CommonMiddleware', 51 | 'django.middleware.csrf.CsrfViewMiddleware', 52 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 53 | 'django.contrib.messages.middleware.MessageMiddleware', 54 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 55 | ] 56 | 57 | ROOT_URLCONF = 'mysite.urls' 58 | 59 | TEMPLATES = [ 60 | { 61 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 62 | 'DIRS': [], 63 | 'APP_DIRS': True, 64 | 'OPTIONS': { 65 | 'context_processors': [ 66 | 'django.template.context_processors.debug', 67 | 'django.template.context_processors.request', 68 | 'django.contrib.auth.context_processors.auth', 69 | 'django.contrib.messages.context_processors.messages', 70 | ], 71 | }, 72 | }, 73 | ] 74 | 75 | WSGI_APPLICATION = 'mysite.wsgi.application' 76 | 77 | 78 | # Database 79 | # https://docs.djangoproject.com/en/2.2/ref/settings/#databases 80 | 81 | DATABASES = { 82 | 'default': { 83 | 'ENGINE': 'django.db.backends.sqlite3', 84 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 85 | } 86 | } 87 | 88 | 89 | # Password validation 90 | # https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators 91 | 92 | AUTH_PASSWORD_VALIDATORS = [ 93 | { 94 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 95 | }, 96 | { 97 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 98 | }, 99 | { 100 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 101 | }, 102 | { 103 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 104 | }, 105 | ] 106 | 107 | 108 | # Internationalization 109 | # https://docs.djangoproject.com/en/2.2/topics/i18n/ 110 | 111 | LANGUAGE_CODE = 'en-us' 112 | 113 | TIME_ZONE = 'UTC' 114 | 115 | USE_I18N = True 116 | 117 | USE_L10N = True 118 | 119 | USE_TZ = True 120 | 121 | 122 | # Static files (CSS, JavaScript, Images) 123 | # https://docs.djangoproject.com/en/2.2/howto/static-files/ 124 | 125 | STATIC_URL = '/static/' 126 | 127 | CRISPY_TEMPLATE_PACK="bootstrap4" 128 | 129 | LOGIN_REDIRECT_URL = "/" 130 | LOGOUT_REDIRECT_URL = "/" -------------------------------------------------------------------------------- /mysite/mysite/urls.py: -------------------------------------------------------------------------------- 1 | """mysite URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/2.2/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: path('', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | from django.contrib import admin 17 | from django.urls import path, include 18 | from register import views as v 19 | 20 | urlpatterns = [ 21 | path('admin/', admin.site.urls), 22 | path("register/", v.register, name="register"), 23 | path('', include("main.urls")), 24 | path('', include("django.contrib.auth.urls")) 25 | ] 26 | 27 | # start -------------------------------------------------------------------------------- /mysite/mysite/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for mysite 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/2.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', 'mysite.settings') 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /mysite/register/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/register/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mysite/register/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/register/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /mysite/register/__pycache__/admin.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/register/__pycache__/admin.cpython-36.pyc -------------------------------------------------------------------------------- /mysite/register/__pycache__/admin.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/register/__pycache__/admin.cpython-37.pyc -------------------------------------------------------------------------------- /mysite/register/__pycache__/apps.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/register/__pycache__/apps.cpython-36.pyc -------------------------------------------------------------------------------- /mysite/register/__pycache__/apps.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/register/__pycache__/apps.cpython-37.pyc -------------------------------------------------------------------------------- /mysite/register/__pycache__/forms.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/register/__pycache__/forms.cpython-36.pyc -------------------------------------------------------------------------------- /mysite/register/__pycache__/forms.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/register/__pycache__/forms.cpython-37.pyc -------------------------------------------------------------------------------- /mysite/register/__pycache__/models.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/register/__pycache__/models.cpython-36.pyc -------------------------------------------------------------------------------- /mysite/register/__pycache__/models.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/register/__pycache__/models.cpython-37.pyc -------------------------------------------------------------------------------- /mysite/register/__pycache__/views.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/register/__pycache__/views.cpython-36.pyc -------------------------------------------------------------------------------- /mysite/register/__pycache__/views.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/register/__pycache__/views.cpython-37.pyc -------------------------------------------------------------------------------- /mysite/register/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from django.contrib.auth import get_user_model 3 | from django.contrib.auth.admin import UserAdmin 4 | 5 | from .forms import RegisterForm, CustomUserChangeForm 6 | from .models import CustomUser 7 | 8 | class CustomUserAdmin(UserAdmin): 9 | add_form = RegisterForm 10 | form = CustomUserChangeForm 11 | model = CustomUser 12 | list_display = ['email', 'username',] 13 | 14 | admin.site.register(CustomUser, CustomUserAdmin) -------------------------------------------------------------------------------- /mysite/register/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class RegisterConfig(AppConfig): 5 | name = 'register' 6 | -------------------------------------------------------------------------------- /mysite/register/forms.py: -------------------------------------------------------------------------------- 1 | from django import forms 2 | from django.contrib.auth.forms import UserCreationForm, UserChangeForm 3 | from .models import CustomUser 4 | 5 | class RegisterForm(UserCreationForm): 6 | email = forms.EmailField() 7 | 8 | class Meta: 9 | model = CustomUser 10 | fields = ["username", "email", "password1", "password2"] 11 | 12 | 13 | class CustomUserChangeForm(UserChangeForm): 14 | 15 | class Meta: 16 | model = CustomUser 17 | fields = ('username', 'email') -------------------------------------------------------------------------------- /mysite/register/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.2 on 2019-04-29 15:20 2 | 3 | import django.contrib.auth.models 4 | import django.contrib.auth.validators 5 | from django.db import migrations, models 6 | import django.db.models.deletion 7 | import django.utils.timezone 8 | 9 | 10 | class Migration(migrations.Migration): 11 | 12 | initial = True 13 | 14 | dependencies = [ 15 | ('auth', '0011_update_proxy_permissions'), 16 | ('main', '0001_initial'), 17 | ] 18 | 19 | operations = [ 20 | migrations.CreateModel( 21 | name='CustomUser', 22 | fields=[ 23 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 24 | ('password', models.CharField(max_length=128, verbose_name='password')), 25 | ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), 26 | ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')), 27 | ('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')), 28 | ('first_name', models.CharField(blank=True, max_length=30, verbose_name='first name')), 29 | ('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')), 30 | ('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')), 31 | ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')), 32 | ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), 33 | ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')), 34 | ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')), 35 | ('toDoLists', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='main.ToDoList')), 36 | ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')), 37 | ], 38 | options={ 39 | 'verbose_name': 'user', 40 | 'verbose_name_plural': 'users', 41 | 'abstract': False, 42 | }, 43 | managers=[ 44 | ('objects', django.contrib.auth.models.UserManager()), 45 | ], 46 | ), 47 | ] 48 | -------------------------------------------------------------------------------- /mysite/register/migrations/__pycache__/0001_initial.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/register/migrations/__pycache__/0001_initial.cpython-36.pyc -------------------------------------------------------------------------------- /mysite/register/migrations/__pycache__/0001_initial.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/register/migrations/__pycache__/0001_initial.cpython-37.pyc -------------------------------------------------------------------------------- /mysite/register/migrations/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/register/migrations/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /mysite/register/migrations/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Django-Website/938adaa7930497a7e7013d427f7038956ae7b460/mysite/register/migrations/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /mysite/register/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | from django.contrib.auth.models import AbstractUser 3 | from main.models import ToDoList 4 | 5 | # Create your models here. 6 | class CustomUser(AbstractUser): 7 | toDoLists = models.ForeignKey(ToDoList, on_delete=models.CASCADE) 8 | -------------------------------------------------------------------------------- /mysite/register/templates/register/register.html: -------------------------------------------------------------------------------- 1 | {% extends 'main/base.html' %} 2 | 3 | {% block titlte %}Register{% endblock %} 4 | 5 | {% load crispy_forms_tags %} 6 | 7 | {% block content %} 8 |
9 |
10 | {% csrf_token %} 11 | Create an Account 12 | {{form|crispy}} 13 | 14 |
15 |
16 | {% endblock %} -------------------------------------------------------------------------------- /mysite/register/templates/registration/login.html: -------------------------------------------------------------------------------- 1 | {% extends "main/base.html"%} 2 | 3 | {% block title%} 4 | {% endblock %} 5 | 6 | {% load crispy_forms_tags %} 7 | 8 | {% block content %} 9 |
10 |
11 | {% csrf_token %} 12 | {{form|crispy}} 13 | 14 |
15 |
16 | {% endblock %} 17 | -------------------------------------------------------------------------------- /mysite/register/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /mysite/register/views.py: -------------------------------------------------------------------------------- 1 | from django.contrib.auth import login, authenticate 2 | from django.contrib.auth.forms import UserCreationForm 3 | from django.shortcuts import render, redirect 4 | 5 | # Create your views here. 6 | def register(response): 7 | if response.method == "POST": 8 | form = UserCreationForm(response.POST) 9 | if form.is_valid(): 10 | form.save() 11 | return redirect("/home") 12 | else: 13 | form = UserCreationForm() 14 | 15 | return render(response, "register/register.html", {"form":form}) -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | django 2 | django-crispy-forms 3 | --------------------------------------------------------------------------------