Answer the question
In order to leave comments, you need to log in
Why does the form with the SelectMultiple widget not work?
I have implemented a form on a page built on a model.
My forms.py file:
class DogRequestsForm(ModelForm):
class Meta:
model = DogRequest
fields = ['id_name', 'Color', 'Dog']
widgets = {
'id_name': NumberInput(attrs={
'class': 'form-control',
'placeholder': 'id_name'
}),
'Color': SelectMultiple(attrs={
'class': 'form-control',
'placeholder': 'Color'
}),
'Dog': SelectMultiple(attrs={
'class': 'form-control',
'placeholder': 'Dog'
}),
}
class DogRequest(models.Model):
id_name=models.PositiveSmallIntegerField()
Colors=models.ForeignKey('Color', on_delete=models.CASCADE, blank=True)
Dogs=models.ManyToManyField('Dog')
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