From 464aa1ab4816cc6037af928bc859eb9d36f7d434 Mon Sep 17 00:00:00 2001 From: Lucas Schumacher Date: Fri, 28 Jun 2024 15:17:58 -0400 Subject: [PATCH] Add Sign Up page --- accounts/__init__.py | 0 accounts/admin.py | 3 +++ accounts/apps.py | 6 ++++++ accounts/migrations/__init__.py | 0 accounts/models.py | 3 +++ accounts/tests.py | 3 +++ accounts/urls.py | 6 ++++++ accounts/views.py | 10 ++++++++++ django_auth/settings.py | 1 + django_auth/urls.py | 1 + templates/home.html | 2 ++ templates/registration/signup.html | 12 ++++++++++++ 12 files changed, 47 insertions(+) create mode 100644 accounts/__init__.py create mode 100644 accounts/admin.py create mode 100644 accounts/apps.py create mode 100644 accounts/migrations/__init__.py create mode 100644 accounts/models.py create mode 100644 accounts/tests.py create mode 100644 accounts/urls.py create mode 100644 accounts/views.py create mode 100644 templates/registration/signup.html diff --git a/accounts/__init__.py b/accounts/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/accounts/admin.py b/accounts/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/accounts/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/accounts/apps.py b/accounts/apps.py new file mode 100644 index 0000000..3e3c765 --- /dev/null +++ b/accounts/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class AccountsConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'accounts' diff --git a/accounts/migrations/__init__.py b/accounts/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/accounts/models.py b/accounts/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/accounts/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/accounts/tests.py b/accounts/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/accounts/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/accounts/urls.py b/accounts/urls.py new file mode 100644 index 0000000..84c732a --- /dev/null +++ b/accounts/urls.py @@ -0,0 +1,6 @@ +from django.urls import path, include +from .views import SignUpView + +urlpatterns = [ + path("signup/", SignUpView.as_view(), name="signup"), +] diff --git a/accounts/views.py b/accounts/views.py new file mode 100644 index 0000000..fcf63ab --- /dev/null +++ b/accounts/views.py @@ -0,0 +1,10 @@ +from django.shortcuts import render + +from django.contrib.auth.forms import UserCreationForm +from django.urls import reverse_lazy +from django.views.generic import CreateView + +class SignUpView(CreateView): + form_class = UserCreationForm + success_url = reverse_lazy("login") + template_name = "registration/signup.html" diff --git a/django_auth/settings.py b/django_auth/settings.py index e8ac2e6..9667a64 100644 --- a/django_auth/settings.py +++ b/django_auth/settings.py @@ -37,6 +37,7 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + "accounts", ] MIDDLEWARE = [ diff --git a/django_auth/urls.py b/django_auth/urls.py index 7316a0b..e834f8a 100644 --- a/django_auth/urls.py +++ b/django_auth/urls.py @@ -20,6 +20,7 @@ from django.views.generic.base import TemplateView urlpatterns = [ path('admin/', admin.site.urls), + path('accounts/', include("accounts.urls")), path('accounts/', include("django.contrib.auth.urls")), path("", TemplateView.as_view(template_name="home.html"), name="home"), ] diff --git a/templates/home.html b/templates/home.html index cb932c5..a8db859 100644 --- a/templates/home.html +++ b/templates/home.html @@ -12,5 +12,7 @@ Hi {{ user.username }}! {% else %}

You are not logged in

Log In +
+Sign Up {% endif %} {% endblock %} diff --git a/templates/registration/signup.html b/templates/registration/signup.html new file mode 100644 index 0000000..59777b0 --- /dev/null +++ b/templates/registration/signup.html @@ -0,0 +1,12 @@ +{% extends "base.html" %} + +{% block title %}Sign Up{% endblock %} + +{%block content %} +

Sign Up

+
+ {% csrf_token %} + {{ form }} + +
+{% endblock %}