Sunday, February 18, 2018

Do I need a special widget for multi-choice fields

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


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f257d5f9-83fe-bde1-c277-c96a67d8184e%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment