Seth Buntin wrote:
> So how will I get the queries if more than one word is used to search?
> The only reason I am using the way I am is in case people search
> multiple words.  Can I run queries and add them together or something?

Seth,

I do a similar thing using the ORM's Q object:
    from django.db.models import Q

    ...

    def search(request):

        terms = request['search'].lower()
        query = Q()
        for term in terms.split(' '):
            q = Q(instName__icontains=term)| \
                Q(instDesc__icontains=term)| \
                Q(instClass__icontains=term)| \
                Q(note__icontains=term)
            query = query & q

        trades = RawTrade.objects.filter(query)

        return render_to_response('trades/search', {'trades': trades,
'search': terms})

This will generate analogous SQL as your case but you don't have to
deal with all the gory SQL details.

-Dave


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

Reply via email to