mirror of
https://github.com/kristoferssolo/FOSSDB.git
synced 2025-10-21 17:50:35 +00:00
Created user registration form
This commit is contained in:
parent
6dc7acbd7c
commit
c3a3d67752
0
FOSSDB_web/apps/account/__init__.py
Normal file
0
FOSSDB_web/apps/account/__init__.py
Normal file
3
FOSSDB_web/apps/account/admin.py
Normal file
3
FOSSDB_web/apps/account/admin.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
||||||
6
FOSSDB_web/apps/account/apps.py
Normal file
6
FOSSDB_web/apps/account/apps.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class AccountConfig(AppConfig):
|
||||||
|
default_auto_field = "django.db.models.BigAutoField"
|
||||||
|
name = "account"
|
||||||
11
FOSSDB_web/apps/account/forms.py
Normal file
11
FOSSDB_web/apps/account/forms.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
from django import forms
|
||||||
|
from django.contrib.auth.forms import UserCreationForm
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
|
|
||||||
|
class RegisterForm(UserCreationForm):
|
||||||
|
email = forms.EmailField(required=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = User
|
||||||
|
fields = ["username", "email", "password1", "password2"]
|
||||||
3
FOSSDB_web/apps/account/tests.py
Normal file
3
FOSSDB_web/apps/account/tests.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
||||||
9
FOSSDB_web/apps/account/urls.py
Normal file
9
FOSSDB_web/apps/account/urls.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
from django.urls import path
|
||||||
|
|
||||||
|
from . import views
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path("", views.sign_up, name="singup"),
|
||||||
|
path("signup", views.sign_up, name="signup"),
|
||||||
|
path("login", views.login_, name="login"),
|
||||||
|
]
|
||||||
20
FOSSDB_web/apps/account/views.py
Normal file
20
FOSSDB_web/apps/account/views.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
from django.contrib.auth import login
|
||||||
|
from django.shortcuts import redirect, render
|
||||||
|
|
||||||
|
from .forms import RegisterForm
|
||||||
|
|
||||||
|
|
||||||
|
def sign_up(request):
|
||||||
|
if request.method == "POST":
|
||||||
|
form = RegisterForm(request.POST)
|
||||||
|
if form.is_valid():
|
||||||
|
user = form.save()
|
||||||
|
login(request, user)
|
||||||
|
return redirect("/")
|
||||||
|
else:
|
||||||
|
form = RegisterForm()
|
||||||
|
return render(request, "registration/sign_up.html", {"form": form})
|
||||||
|
|
||||||
|
|
||||||
|
def login_(request):
|
||||||
|
return render(request, "registration/login.html")
|
||||||
@ -24,7 +24,6 @@ DEBUG = BASE_PATH.joinpath("debug").is_file()
|
|||||||
|
|
||||||
# Quick-start development settings - unsuitable for production
|
# Quick-start development settings - unsuitable for production
|
||||||
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/
|
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/
|
||||||
|
|
||||||
with open(BASE_PATH.joinpath("config.json"), "r", encoding="UTF-8") as config_file:
|
with open(BASE_PATH.joinpath("config.json"), "r", encoding="UTF-8") as config_file:
|
||||||
config = json.load(config_file)
|
config = json.load(config_file)
|
||||||
|
|
||||||
@ -37,6 +36,7 @@ ALLOWED_HOSTS = config["ALLOWED_HOSTS"]
|
|||||||
# Application definition
|
# Application definition
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
|
"account",
|
||||||
"django.contrib.admin",
|
"django.contrib.admin",
|
||||||
"django.contrib.auth",
|
"django.contrib.auth",
|
||||||
"django.contrib.contenttypes",
|
"django.contrib.contenttypes",
|
||||||
|
|||||||
@ -14,8 +14,10 @@ Including another URLconf
|
|||||||
2. Add a URL to urlpatterns: path("blog/", include("blog.urls"))
|
2. Add a URL to urlpatterns: path("blog/", include("blog.urls"))
|
||||||
"""
|
"""
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path
|
from django.urls import include, path
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("admin/", admin.site.urls),
|
path("admin/", admin.site.urls),
|
||||||
|
path("", include("django.contrib.auth.urls")),
|
||||||
|
path("account/", include("account.urls")),
|
||||||
]
|
]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user