Improved subject selection in django admin for custom user

This commit is contained in:
Keannu Bernasol 2023-09-12 20:06:41 +08:00
parent 36aecbbfb4
commit 4fcd9ae154

View file

@ -6,6 +6,7 @@ from year_levels.models import Year_Level
from semesters.models import Semester from semesters.models import Semester
from courses.models import Course from courses.models import Course
from subjects.models import SubjectInstance from subjects.models import SubjectInstance
from django.contrib.admin.widgets import FilteredSelectMultiple
class CustomUserForm(forms.ModelForm): class CustomUserForm(forms.ModelForm):
@ -22,7 +23,7 @@ class CustomUserForm(forms.ModelForm):
course = forms.ModelChoiceField( course = forms.ModelChoiceField(
queryset=Course.objects.all(), required=False) queryset=Course.objects.all(), required=False)
subjects = forms.ModelMultipleChoiceField( subjects = forms.ModelMultipleChoiceField(
queryset=SubjectInstance.objects.none(), required=False, widget=forms.CheckboxSelectMultiple) queryset=SubjectInstance.objects.none(), required=False, widget=FilteredSelectMultiple("Subjects", is_stacked=False))
avatar = forms.ImageField(required=False) avatar = forms.ImageField(required=False)
class Meta: class Meta: