On 11/04/2008, Brian Morton <[EMAIL PROTECTED]> wrote:
[...]
>  The problem occurs in the template.  I am trying to differentiate
>  these fields from the other normal fields on the form for presentation
>  purposes.  I have tried assigning a custom property to each of the
>  dynamic fields.
>
>  field = forms.BooleanField(label='%s (%s)' % (song.title, " &
>  ".join([str(artist) for artist in song.artists.all()])))
>  field.is_song = True
>  self.fields['song_%s' % song.id] = field
>
>  However, this custom property is not accessible in the template.  How
>  can I differentiate these dynamic fields from the others in the
>  template (with limited access to Python code)?

If your template looks something like:

  {% for field in form %}
    {% if field._is_song %}
        ...

then the for loop 'field' is actually a boundfield instance which
wraps the real field. To get to the real field use 'field.field' in
the template. I.e. your template would look like:

   {% for field in form %}
     {% if field.field.is_song %}
        ...

-- 
Phil Davis

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to