Better age check
This commit is contained in:
@@ -49,10 +49,12 @@ class MembershipForm(forms.ModelForm):
|
||||
self.add_error(fieldname, errormsg)
|
||||
if membership and cleaned_data.get('birthday'):
|
||||
birthday = cleaned_data.get('birthday')
|
||||
print("Today:", date.today())
|
||||
print("Birthday:", birthday)
|
||||
if date.today().year - cleaned_data.get('birthday').year < 16:
|
||||
self.add_error('birthday', 'Midestalter für Mitlieder ist 16 Jahre!')
|
||||
today = date.today()
|
||||
age = today.year - birthday.year - (
|
||||
(today.month, today.day) < (birthday.month, birthday.day))
|
||||
if age < 16:
|
||||
self.add_error('birthday',
|
||||
'Midestalter für Mitlieder ist 16 Jahre!')
|
||||
|
||||
|
||||
class RegistrationForm(MembershipForm):
|
||||
|
||||
Reference in New Issue
Block a user