diff --git a/teachers/forms.py b/teachers/forms.py index 53dd294..64f6bbf 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']