Tuesday, July 31, 2012

Re: merge data from multiple models

Hi there,

> As templates cannot do lookups into a dictionary....

Templates can do lookups into a dictionary, see
https://docs.djangoproject.com/en/1.4/topics/templates/#variables
(check the "Behind the scenes" section).

From what you've described, I'd try to prepare the necessary data in
a view (using caching, if possible at all), build the appropriate data
structure to be displayed and then use the template layer to do a
"dummy" display. Then you'd have the full power of Python at your
disposal to perform the best access to your data and combining the
models together into and array of items or a dictionary, depending on
your need.

HTH

Jirka

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