mirror of
https://github.com/lemeow125/StudE-Backend.git
synced 2024-11-17 06:19:24 +08:00
Fixed admin page for customuser
This commit is contained in:
parent
66fdc16524
commit
aeecd1a77c
1 changed files with 6 additions and 4 deletions
|
@ -5,15 +5,17 @@ from .models import CustomUser
|
|||
from year_levels.models import Year_Level
|
||||
from semesters.models import Semester
|
||||
from courses.models import Course
|
||||
from subjects.models import Subject
|
||||
from subjects.models import SubjectInstance
|
||||
|
||||
|
||||
class CustomUserForm(forms.ModelForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(CustomUserForm, self).__init__(*args, **kwargs)
|
||||
if self.instance:
|
||||
self.fields['subjects'].queryset = Subject.objects.filter(
|
||||
course=self.instance.course)
|
||||
self.fields['subjects'].queryset = SubjectInstance.objects.filter(
|
||||
course=self.instance.course).filter(
|
||||
year_level=self.instance.year_level).filter(
|
||||
semester=self.instance.semester)
|
||||
|
||||
year_level = forms.ModelChoiceField(
|
||||
queryset=Year_Level.objects.all(), required=False)
|
||||
|
@ -22,7 +24,7 @@ class CustomUserForm(forms.ModelForm):
|
|||
course = forms.ModelChoiceField(
|
||||
queryset=Course.objects.all(), required=False)
|
||||
subjects = forms.ModelMultipleChoiceField(
|
||||
queryset=Subject.objects.none(), required=False, widget=forms.CheckboxSelectMultiple)
|
||||
queryset=SubjectInstance.objects.none(), required=False, widget=forms.CheckboxSelectMultiple)
|
||||
avatar = forms.ImageField(required=False)
|
||||
|
||||
class Meta:
|
||||
|
|
Loading…
Reference in a new issue