You could try this:
kwargs = {}
if request['price']:
kwargs['id'] = request['price']
a = Price.objects.filter(**kwargs)
--
Tõnis Kevvai
"How can entropy be reversed?"
On 8/6/07, Greg <[EMAIL PROTECTED]> wrote:
>
> Hello,
> I have a form that will contain 3 select input types. The user is
> going to have the ability to narrow down the products by selecting a
> value in these 3 select boxes (Price, Size, Color). However, the user
> also has the ability to not select anything. In this case I would
> want to return all the records. Is there a way in django that I can
> do this? This is what I currently have for Price:
>
> a = Price.objects.filter(id=request['price'])
>
> If the user selected a price then the request['price'] would equal the
> id of the price record. However, if the user didn't select a price.
> Then I'd want request['price'] to be a value that wouldn't exclude any
> record in the Price table. Such as:
>
> a = Price.objects.filter(id=*) #???? So request['price'] would equal *
> in this example
>
> I can't use a = Price.objects.all(), because I won't know beforehand
> if the user selected a price to search for.
>
>
> Thanks
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---