Django Projektordner von 'core' in ''django' umbenennen

This commit is contained in:
juhnsa
2025-03-15 21:48:35 +01:00
parent 230944cbcd
commit 55750bcf1f
91 changed files with 0 additions and 0 deletions

View File

3
django/accounts/admin.py Normal file
View File

@@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

6
django/accounts/apps.py Normal file
View File

@@ -0,0 +1,6 @@
from django.apps import AppConfig
class AccountsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'accounts'

22
django/accounts/forms.py Normal file
View File

@@ -0,0 +1,22 @@
from django import forms
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from django import forms
class RegisterForm(UserCreationForm):
class Meta:
model=User
fields = ['username','password1','password2']
username = forms.CharField(
widget=forms.TextInput(attrs={'placeholder': 'BENUTZERNAME'})
)
password1 = forms.CharField(
widget=forms.PasswordInput(attrs={'placeholder': 'PASSWORT'})
)
password2 = forms.CharField(
widget=forms.PasswordInput(attrs={'placeholder': 'PASSWORT WIEDERHOLEN'})
)

View File

View File

@@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

3
django/accounts/tests.py Normal file
View File

@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

16
django/accounts/urls.py Normal file
View File

@@ -0,0 +1,16 @@
from django.urls import path # type: ignore
from . import views
from django.contrib.auth.views import LogoutView
from django.contrib.auth.views import LoginView
app_name = 'accounts' # Namensraum zum verhindern von Konflikten zwischen Apps
#
# Wichtig: Damit Links funktionieren müssen diese so eingebunden werden: {% url 'accounts:login' %} statt {% url 'login' %}
#
urlpatterns = [
path('', views.home, name='home'),
path('logout/', LogoutView.as_view(next_page='accounts:login'), name='logout'),
path('login/', LoginView.as_view(template_name='accounts/login.html', next_page='accounts:home'), name='login'),
path('register/', views.register, name='register'),
]

19
django/accounts/views.py Normal file
View File

@@ -0,0 +1,19 @@
from django.shortcuts import render, redirect
from django.contrib.auth.decorators import login_required
from .forms import RegisterForm
# Create your views here.
@login_required
def home(request):
return render(request, 'accounts/home.html')
def register(response):
if response.method == "POST":
form = RegisterForm(response.POST)
if form.is_valid():
form.save()
return redirect("home")
else:
form = RegisterForm()
return render(response, "accounts/register.html", {"form":form})