> if request['color'] == "---------------": # This means no color was
> selected
>     mycolor = ColorCategory.objects.all()
> else:
>     mycolor = request['color']
> ...
> i = Choice.objects.get(id=h.id).style_set.filter(color_cat=mycolor)
> 
> ////////////////////
> 
> So, as you can probably see when a color type is selected then mycolor
> is set to request['color'].  However, when a color is not selected
> then mycolor is set to 'ColorCategory.objects.all().  Then later in my
> view when I try to do a
> 
> filter(color_cat=mycolor)
> 
> It errors out because mycolor is equal to a list of ColorCategory
> objects.  I need mycolor to equal any ColorCategory number.  Does
> anybody know how to do that?

It sounds like you just want to filter selectively:

   NO_COLOR = '------------'
   styles = Choice.objects.get(id=h.id).style_set
   if 'color' in request and request['color'] <> NO_COLOR:
     styles = styles.filter(color_cat=request['color'])

   for style in styles:
     do_something(style)

-tim




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