Ok, I've found sort of solution, relatively quick so, I'm happy

CODE:

FRUITS = [
'apples', 'lemons', 'strawberries',
] # hardcoded like here or from db

ANSWERS = [
(0, u''),
(1, u'selling'),
(2, u'making'),
(3, u'both'),
] # hardcoded like here or from db

class ProblematicForm(forms.Form):
    regular_field = forms.CharField()

    def __init__(self, *args, **kwargs):
        super(ProblematicForm, self).__init__(*args, **kwargs)
        for name in FRUITS:
             # Here we add our problematic fields
             self.fields[name] = forms.ChoiceField(choices=ANSWERS)


This won't give fieldset (like in linked example), but it wouldn't have.


On Sunday, July 21, 2013 6:56:25 PM UTC+2, Tymoteusz Jankowski wrote:
>
> I have 2 things:
> - list of fruits (eg.: apples, lemons, strawberries)
> - list of answers (eg.: 'selling', 'making', 'both')
>
> How can i merge these lists into django form which products something like 
> the html here <http://jsfiddle.net/2DVvG/>.
>
> The desired form would allow user to pick an ONE answer ('selling', 
> 'making', 'both') for each fruit (apples, lemons, starberries)
>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to