RajeshD, I implemented what you said. Here is my attempt: choice_ids = [c.id for c in y] styles = Style.objects.filter(sandp__choice__in=choice_ids) if ('color' in request.POST) and (request.POST['color'] <> NOT_PICKED): styles = styles.filter(color_cat=request['color']) myset.add(styles) assert False, myset
//////////// When it encounters the 'assert False, myset'. I see a set within a list within a list: AssertionError at /rugs/searchresult/ set([[<Style: Ionica>, <Style: Ionica>, <Style: Ionica>, <Style: Ionica>, <Style: Ionica>]]) ////////// It's bringing back the right records (not filtered though), however they are not visible. Probably because of a list within a list. Thanks On Aug 9, 4:29 pm, RajeshD <[EMAIL PROTECTED]> wrote: > 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 -~----------~----~----~----~------~----~------~--~---