python - django multiple choices with yes no options -



python - django multiple choices with yes no options -

consider model

test = industry.objects.all()

and result is

[<industry: test 1>, <industry: test 2>, <industry: test 3>]

my model field is

options = models.manytomanyfield(industry, default='')

and in forms.py

options = forms.modelmultiplechoicefield(widget=forms.checkboxselectmultiple(attrs={'class':'contract-text-fld'}), queryset=industry.objects.all(), required=false)

as know outpu form looks like

checkbox1 checkbox1 checkbox1

but need this

label1 yes(radio) no(radio) label2 yes(radio) no(radio) label3 yes(radio) no(radio)

is possible if yes how can handle this?

there no standard widget display manytomanyfield in way like. need write custom widget this.

base widget documentation useful: https://docs.djangoproject.com/en/dev/ref/forms/widgets/

a tutorial on how write custom widget: http://tothinkornottothink.com/post/10815277049/django-forms-i-custom-fields-and-widgets-in-detail

python django django-templates

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -