From 93263ff13a0284df25cb65fb9a5cc6042567b037 Mon Sep 17 00:00:00 2001 From: aadilrashidd Date: Thu, 18 Apr 2024 19:12:31 +0500 Subject: [PATCH] add current year in signup page --- teachers/forms.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/teachers/forms.py b/teachers/forms.py index 53dd294a..64f6bbf7 100644 --- a/teachers/forms.py +++ b/teachers/forms.py @@ -4,8 +4,8 @@ from django.forms import ModelForm from django import forms from easyschool.utils import GENDER_CHOICES - - +from django.core.exceptions import ValidationError +from datetime import datetime class TeacherSignUpForm(forms.ModelForm): password1 = forms.CharField( label='Password', @@ -20,14 +20,16 @@ class TeacherSignUpForm(forms.ModelForm): label="Username", required=True) - date_of_joining = forms.DateField(widget=forms.SelectDateWidget(years=range(1960, 2020))) - date_of_birth = forms.DateField(widget=forms.SelectDateWidget(years=range(1960, 2020))) + next_year=datetime.now().year +1 + date_of_joining = forms.DateField(widget=forms.SelectDateWidget(years=range(1960,next_year))) + date_of_birth = forms.DateField(widget=forms.SelectDateWidget(years=range(1960,next_year ))) gender = forms.ChoiceField(choices= GENDER_CHOICES) - cnic = forms.CharField(max_length=15) + cnic = forms.CharField(max_length=20) phone_no = forms.CharField(max_length=12) is_teaching = forms.BooleanField(label= 'Presently teaching in this school',required=False) address = forms.CharField(max_length=150, required=True) profile_image = forms.ImageField(required=False, label='Profile Picture') + def clean_email(self): email = self.cleaned_data['email']