You probably want to use "Complex lookups with Q objects" (http:// www.djangoproject.com/documentation/db-api/)
here is how i use it on a site: from django.db.models import Q query = Q() for term in request.GET['area'].split(' '): q = Q(city__icontains = term) \ |Q(postcodeFirstPart__iexact = term) \ |Q(street1__icontains = term) \ |Q(street2__icontains = term) \ |Q(suburb__icontains = term) \ |Q(referenceID0__icontains = term) \ |Q(referenceID1__icontains = term) query = query & q (this is only one part of the bigger search query for a property system) "term" is the search term from you search box (called "area" here). You can chain them up in OR & AND .. finally you just call object_list = Property.objects.all().filter(query, isLive=True) with your query. this should get you started .. On Nov 4, 2:01 am, Greg <[EMAIL PROTECTED]> wrote: > Hello, > I've created a django website where I sell many different products, > that differ by color, manufacturer, size, price, shape, etc... I'm > wondering what the best way to implement a search box would be. I'd > want this search box to return only the products that relate to what > the user searches for. > > I'd imagine I'll have to break the search terms up into a list. So if > the user searches for Red Aadi Sphinx. Then I'd put those words into > a list ['Red', 'Aadi', 'Sphinx']. And then take each one of the words > and search every class that I have in my models.py file and if I get > any matches then I'd append that to my search list. > > Does anybody have any suggestions on how best to do this? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---