Can anybody help me in this
Thank you in advance;
Mary Adel
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]
Thank you in advance
Mary Adel
On Feb 23, 1:37 pm, "Aidas Bendoraitis" <aidas.bendorai...@gmail.com>
wrote:
> Just filter searchable models according the searchable fields by the
> user-input. You'll need a form with a field forsearchstring. 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 cansearchin title and content of
> flat pages and in title and description of products.
>
> To make thesearcheven more flexible, you can parse the search_str
> into chunks considering that spaces react as OR operators (like in the
> popularsearchengines) 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 <madelghat...@gmail.com> wrote:
>
>
>
> > How can i add asearchfeature to my website?
from django.db.models import Q
Hi Mary,
have a look at these two snippets:
http://www.djangosnippets.org/snippets/31/ (long version, easier to
understand the principle)
http://www.djangosnippets.org/snippets/32/ (compact version)
L.
Thank you in advance --
Mary Adel
:(
On Mar 19, 2:50 pm, "lbologn...@gmail.com" <lbologn...@gmail.com>
wrote:
> On Feb 22, 11:07 pm, "Mary" <madelghat...@gmail.com> wrote:
>
> > How can i add asearchfeature to my website?
>
> > Can anybody help me in this
>
> HiMary,
>
> have a look at these two snippets:http://www.djangosnippets.org/snippets/31/(long version, easier to
I've used it on 2 sites and they're non-commercial so I can switch off
the ads. It took some time for google's indexing to settle down, but
it seems to work fine now.
Derek