On Jan 21, 2:14 pm, Shawn Milochik <sh...@milochik.com> wrote: > What did you try? > > I found it easily. > > First: > print dir(myform) > #I found that myform has a 'fields' attribute. > > Second: > print dir(myform.fields['choicefieldname']) > > #found myform.fields['choicefieldname'].choices > > Third: > print myform.fields['choicefieldname'].choices > #got all the nice options I was looking for! > > Then, in my template: > > {% for choice_value, choice_text in > myform.fields.choicefieldname.choices %} > choice_value: {{ choice_value }}<br/> > choice_text: {{ choice_text }}<br/> > {% endfor %} > > Shawn
I think there might be a terminology issue here. I suspect the OP is looking for all the possible value of a model field with `choices` set. Which, is not easily possible from a template (although you can do it in Python: MyModel._meta.get_field_by_name('myfield') [0].choices) -- DR.
-- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.