FloriCore/member/forms.py

31 lines
907 B
Python
Raw Normal View History

# forms.py
from django import forms
2025-07-05 11:49:07 +02:00
from .models import Person, UserAccount
class PersonForm(forms.ModelForm):
class Meta:
model = Person
fields = ['vorname', 'nachname', 'geburtsdatum', 'aktiv']
widgets = {
'geburtsdatum': forms.DateInput(attrs={'type': 'date'}),
}
2025-07-05 11:49:07 +02:00
class AccountForm(forms.ModelForm):
password=forms.CharField(widget=forms.PasswordInput())
confirm_password=forms.CharField(widget=forms.PasswordInput())
class Meta:
model = UserAccount
fields = ['username', 'password']
def clean(self):
cleaned_data = super(AccountForm, self).clean()
passwordStr = cleaned_data.get("password")
confirm_passwordStr = cleaned_data.get("confirm_password")
if passwordStr != confirm_passwordStr:
raise forms.ValidateError("password and confirm_password does not match")