Do I need a special widget for multi-choice fields

5 views
Skip to first unread message

Mike Dewhirst

unread,
Feb 19, 2018, 2:08:18 AM2/19/18
to Django users
The use case is on-line training software for a trainer entering a bunch
of statements as possible answers to a single question. The student user
needs to see this as a bunch of corresponding radio-buttons or select
drop-down for a single answer selection.

I've looked at the docs:
https://docs.djangoproject.com/en/1.11/ref/forms/widgets/#widgets-inheriting-from-the-select-widget

and
https://docs.djangoproject.com/en/1.11/ref/forms/widgets/#select

I'm using a ModelForm but the model's answer field does not use choices.
The possible answers are all in (up to) six separate fields on the same
model. I know this is premature denormalisation but it seemd like a good
idea at the time.

Do I need to build a special widget which harvests the possibilities
from those separate fields?

Maybe I have to construct the choices in a callable?

Is there a better way?

Thanks for any light

Cheers

Mike


Reply all
Reply to author
Forward
0 new messages