Here is the piece of code for the form field
{{{
class Media:
css = {
'all': ('/static/admin/css/widgets.css',),
}
js = ('/admin/jsi18n',)
dental_codes = forms.ModelMultipleChoiceField(
label='Select Proccedure Codes',
queryset = CDTADACodes.objects.all(),
widget = FilteredSelectMultiple('Dental Codes Selection',
is_stacked=True),
required = False
)
}}}
Here is the html template
{{{
<div class="row justify-content-md-center">
<div class="form-group">
{{form.media}}
{{form.dental_codes.errors}}
{{form.dental_codes}}
</div>
</div>
}}}
Template is correctly loaded in Front End but no values are selected when
used. Only by commenting the widget assignment sentence the code works
correctly.
Any help is welcomed, thanks in advance
--
Ticket URL: <https://code.djangoproject.com/ticket/33857>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => invalid
Comment:
It works for me in the admin, so it's probably an issue in your code. I
used the following form:
{{{
class MyBrushForm(forms.ModelForm):
dental_codes = forms.ModelMultipleChoiceField(
label='Select Proccedure Codes',
queryset = DentalCode.objects.all(),
widget = FilteredSelectMultiple('Dental Codes Selection',
is_stacked=True),
required = False,
)
code = forms.IntegerField()
class Meta:
model = Brush
fields = ['code', 'dental_codes']
class BrushAdmin(admin.ModelAdmin):
form = MyBrushForm
}}}
Moreover Django 2.2 is not supported anymore, you can try to use Django
4.0+.
See TicketClosingReasons/UseSupportChannels for ways to get help.
--
Ticket URL: <https://code.djangoproject.com/ticket/33857#comment:1>