feat: add school management auth and student CRUD UI

This commit is contained in:
Sina
2026-09-24 23:34:21 +03:30
parent 12e9efcb5c
commit 8a196f8c4f
20 changed files with 326 additions and 9 deletions

20
students/forms.py Normal file
View File

@@ -0,0 +1,20 @@
from django import forms
from .models import Student
class StudentForm(forms.ModelForm):
class Meta:
model = Student
fields = ('first_name', 'last_name', 'age', 'grade')
widgets = {
'first_name': forms.TextInput(attrs={'placeholder': 'مثلاً: سارا'}),
'last_name': forms.TextInput(attrs={'placeholder': 'مثلاً: احمدی'}),
'age': forms.NumberInput(attrs={'min': 5, 'max': 25, 'placeholder': 'سن'}),
}
def clean_age(self):
age = self.cleaned_data['age']
if not 5 <= age <= 25:
raise forms.ValidationError('سن باید بین ۵ تا ۲۵ سال باشد.')
return age