Add Sign Up page
This commit is contained in:
parent
5f8fe95ef1
commit
464aa1ab48
0
accounts/__init__.py
Normal file
0
accounts/__init__.py
Normal file
3
accounts/admin.py
Normal file
3
accounts/admin.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
6
accounts/apps.py
Normal file
6
accounts/apps.py
Normal file
@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class AccountsConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'accounts'
|
||||
0
accounts/migrations/__init__.py
Normal file
0
accounts/migrations/__init__.py
Normal file
3
accounts/models.py
Normal file
3
accounts/models.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
3
accounts/tests.py
Normal file
3
accounts/tests.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
6
accounts/urls.py
Normal file
6
accounts/urls.py
Normal file
@ -0,0 +1,6 @@
|
||||
from django.urls import path, include
|
||||
from .views import SignUpView
|
||||
|
||||
urlpatterns = [
|
||||
path("signup/", SignUpView.as_view(), name="signup"),
|
||||
]
|
||||
10
accounts/views.py
Normal file
10
accounts/views.py
Normal file
@ -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"
|
||||
@ -37,6 +37,7 @@ INSTALLED_APPS = [
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
"accounts",
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
||||
@ -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"),
|
||||
]
|
||||
|
||||
@ -12,5 +12,7 @@ Hi {{ user.username }}!
|
||||
{% else %}
|
||||
<p>You are not logged in</p>
|
||||
<a href="{% url 'login' %}">Log In</a>
|
||||
<br />
|
||||
<a href="{% url 'signup' %}">Sign Up</a>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
12
templates/registration/signup.html
Normal file
12
templates/registration/signup.html
Normal file
@ -0,0 +1,12 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Sign Up{% endblock %}
|
||||
|
||||
{%block content %}
|
||||
<h2>Sign Up</h2>
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
{{ form }}
|
||||
<button type="submit">Sign Up</button>
|
||||
</form>
|
||||
{% endblock %}
|
||||
Loading…
x
Reference in New Issue
Block a user