hi,
i'm trying to implement a dynamic table in django.
every column of the table is coded as a python object and i want
to pass a list of these objects to the template as the context.

every object has a method which runs a rather expensive
query on the database and returns a list which can be empty.

my problem is that when this list is empty i want to branch in the
template,
and display some sort of message, instead of the usual 'for' loop
which would
display the returned list. since i can't assign the returned list to a
variable
i have to check the method's return value first with an 'if' tag than
run the query
again for the 'for' loop. this doubles the load on the db what i don't
like, not to mention
that the two queries may return different lists.

am i missing something? do i follow a bad pattern? why i can't extend
the
context from inside a template?

thanks
bmt

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