I'm struggling with the template system.

I have a Display model. This model will render its elements, which are
of different model types. They are of type Addressbook, Schedule,
Whiteboard, and so on.

I'm trying to figure out how I can loop in the Display template and
call each element's respective template tag to render the snippet.

 For instance,
{% for e in elements %}
       <p>{{ e.call_respective_model_rendering_function }}</p>
{% endfor %}

elements is a list of model objects of differing type

I've been playing with inclusion tags, but what would be the proper
way to determine the element's model type and then call the proper
method?

Here's an example of one of the inclusion tags I wrote to give a
better idea of what I've been trying to do.

@register.inclusion_tag('addressbook/display.html')
def show_addressbook(addressbook):
    contacts = addressbook.contact_set.all()
    return {'name': addressbook.name, 'contacts': contacts}

Can anyone help me, please?


--~--~---------~--~----~------------~-------~--~----~
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