Try changing this fragment:

for q in y:
   styles = Choice.objects.get(id=q.id).style_set.all()

to something like this:

choice_ids = [c.id for c in y]
styles = Style.objects.filter(choice__id__in=choice_ids).distinct()

If that works, you shouldn't need a set or a map to weed out
duplicates.

Incidentally, set() doesn't do the trick for you because you get two
different instances of the Style model class. Granted that they both
represent the same row of data in your DB but they are still two
different Python object instances unless you add comparison methods in
your Style class that make it seem to Python that they are the same
object.




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