I have a forms.Form that has fields in it, and I'm dynamically
creating custom fields, each with a name beginning with 'custom_.'
In my template I'm already displaying the non-custom fields. I need to
be able to show just the custom fields.
How do I iterate through only the custom fields in my template?
What I've tried:
Adding a copy() of self.fields named custom_fields in the form so
I could iterate through custom_fields in the template, but the fields
will not display.
Saved the names of the custom fields in a list, and in the
template tried iterating though those like so:
{% for fieldname in form.custom_field_names %}
{{ additional_content.form.fieldname }}<br/>
{# this doesn't work #}
{{ additional_content.form.fields.fieldname }}{# neither does this #}
{% endfor %}
I'm assuming some special handling of the fields is happening during
template rendering which thwarts my attempted workarounds.
Thanks,
Shawn
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment