Answer the question
In order to leave comments, you need to log in
Booleanfield and multiple choice?
I'm trying to make a multiple choice on the site in the admin panel using the BooleanField field.
In models.py:
class School(models.Model):
CATEGORY_CHOICES = (
('a', 'A'),
('a1', 'A1'),
('b', 'B'),
('b1', 'B1'),
('be', 'BE'),
('c', 'C'),
('c1', 'C1'),
('ce', 'CE'),
('c1e', 'C1E'),
('d', 'D'),
('d1', 'D1'),
('de', 'DE'),
('d1e', 'D1E'),
('e', 'E'),
('m', 'M'),
('tm', 'TM'),
('tb', 'TB'),
)
category_education = models.BooleanField(choices=CATEGORY_CHOICES, default=False, verbose_name='Категория обучения', blank=True)
class SchoolAdminForm(forms.ModelForm):
class Meta:
model = School
widgets = {
'category_education': CheckboxSelectMultiple(),
}
fields = '__all__'
class SchoolAdmin(admin.ModelAdmin):
form = SchoolAdminForm
admin.site.register(School, SchoolAdmin)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question