Hello all, i have a question about a certain query i have. Here is my model setup:
class Term(): term = CharField() class Image(): image = FileField() terms = ForeignKey(Term) These have been abbreviated for simiplicity, ut you get the gist of it. Anyhow i have to query for a few hundred Image objects, then get a list of Term objects for each of these. Really i just need the IDs of the Terms. Currently i have my query like this: images = Image.objects.all() responseImages = [] for i in images: terms = [term.id for term in n.terms.all()] responseObjects.append({'image': n, 'terms': terms}) Am i losing some efficiency here? Seems like a fairly common operation, but I think each of the list comprehensions is a db hit. on ~300 objects, thats a lot of queries. Any advice on this one? Thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.