tried {{ issue.x }} x = 0,1,2,3 but nothing is displayed in the template

any other thoughts?

On Monday, 3 September 2012 22:53:03 UTC+1, somecallitblues wrote:
>
> Try {{ issue.0}} and {{ issue.1}}
> On Sep 4, 2012 5:55 AM, "mjh" <martin.jam...@gmail.com <javascript:>> 
> wrote:
>
>> Hi all - not sure how to show the choicefield dropdown in my template?
>>
>> Am generating a dynamic form (note: for issue in issues in forms.py) and 
>> appending the fields to self.issue_list
>>
>> in the template I am looping over these fields ({% for issue in 
>> form.issue_list %}) and can write out the label {{ issue.label }} but if 
>> write out {{ issue }} I simply get the bound field object written to 
>> template (<django.forms.fields.ChoiceField object at 0x40d03d0>).
>>
>> Question is how do I get the html dropdown to display in the template??
>>
>>
>>
>> >>> forms.py
>>     def __init__(self, item, *args, **kwargs):
>>         super(ItemAnalysisForm, self).__init__(*args, **kwargs)
>>         issue_choice = (('1', 'Reduced'),
>>                         ('2', 'Maintained'),
>>                         ('3', 'Increased')
>>             )
>>         issues = item.issue.all()
>>
>>         self.issue_list = []
>>         self.a_list = []
>>         # generate dynamic issue dropdowns...
>>         for issue in issues:
>>             self.fields['issue-' + str(issue.pk)] = 
>> forms.ChoiceField(label=issue.name, choices=issue_choice, required=False)
>>             self.a_list.append(self.fields['issue-' + str(issue.pk)])
>>             self.issue_list.append(self.fields['issue-' + str(issue.pk)])
>>         self.fields['text'] = forms.CharField(label='text', required=True, 
>> widget=forms.Textarea(attrs={'rows':25,'cols':'100'}))
>>         self.a_list.append(self.fields['text'])
>>
>>
>> >>> template
>>     <form method="post" action="." name="form" id="item_analysis_form">{% 
>> csrf_token %}
>>         <fieldset class="module">
>>             <h2>Individual Issue Outcome:</h2>
>>             <div class="form-row">
>>                 {% for issue in form.issue_list %}
>>                     <div class="form-row">
>>                         {{ issue.label }}: {{ issue }}
>>                     </div>
>>                 {% endfor %}
>>             </div>
>>         </fieldset>
>>         <fieldset class="module aligned ">
>>             <h2>Comment:</h2>
>>             <div class="form-row">
>>                 {{ form.text }}</div>
>>         </fieldset>
>>
>>     </form>
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/django-users/-/XSMbUGOJyvMJ.
>> To post to this group, send email to django...@googlegroups.com<javascript:>
>> .
>> To unsubscribe from this group, send email to 
>> django-users...@googlegroups.com <javascript:>.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/T4kUV4SutHkJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to