diff --git a/src/membership/forms.py b/src/membership/forms.py index cf92d96..c685344 100644 --- a/src/membership/forms.py +++ b/src/membership/forms.py @@ -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):