Just filter searchable models according the searchable fields by the user-input. You'll need a form with a field for search string. And a view for results with something like: flatpages = FlatPage.objects.filter(Q(title__contains=search_str) | Q(content__contains=search_str)) products = Product.objects.filter(Q(title__contains=search_str) | Q(description__contains=search_str)) ... if consider that the visitor can search in title and content of flat pages and in title and description of products.
To make the search even more flexible, you can parse the search_str into chunks considering that spaces react as OR operators (like in the popular search engines) and then to form some complex filter arguments and pass them to the filter method using *args and **kwargs, like this flatpage_args = ... # OR'ed arguments flatpage_kwargs = ... # arguments to AND flatpages = FlatPage.objects.filter(*flatpage_args, **flatpage_kwargs) product_args = ... # OR'ed arguments product_kwargs = ... # arguments to AND products = Product.objects.filter(*product_args, **product_kwargs) Regards, Aidas Bendoraitis [aka Archatas] On 2/22/07, Mary <[EMAIL PROTECTED]> wrote: > > How can i add a search feature to my website? > > Can anybody help me in this > > Thank you in advance; > Mary Adel > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---