I am looking for best way to access object attributes described in a
external list.
The user case is to display a list of objects for different classes showing
only some attributes, every list will contain only objects of the same
kind, all the functionality repeats except the attributes to be displayed
that vary according to the list.
In the view I have a factory that retrieves the different
objects transparently.

The two solutions I have now are:

1) Iterate through attributes:

items: is a list of items of the same kind
item_display_field: is a list of field to be displayed
getattribute: is a custom filter

{% for item in items %}
>     {% for field in item_display_field %}
>         {{ item | getattribute:field }}
>     {% endfor  %}
> </br>
> {% endfor  %}


2) Faster but less DRY is to keep the view factory but specify different
templates according the class, I will have to repeat the code but win
the processor time used to iterate through attributes.

Is there a better way to do it in Django templates?

Thanks

-- 
Serge G. Spaolonzi
Cobalys Systems
http://www.cobalys.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to