Google Groups Home
Help | Sign in
Search feature
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Expand all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Mary  
View profile  
 More options Feb 22 2007, 5:07 pm
From: "Mary" <madelghat...@gmail.com>
Date: Thu, 22 Feb 2007 22:07:29 -0000
Local: Thurs, Feb 22 2007 5:07 pm
Subject: Search feature
How can i add a search feature to my website?

Can anybody help me in this

Thank you in advance;
Mary Adel


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Aidas Bendoraitis  
View profile  
 More options Feb 23 2007, 6:37 am
From: "Aidas Bendoraitis" <aidas.bendorai...@gmail.com>
Date: Fri, 23 Feb 2007 12:37:27 +0100
Local: Fri, Feb 23 2007 6:37 am
Subject: Re: Search feature
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 <madelghat...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mary  
View profile  
 More options Mar 18 2007, 1:49 pm
From: "Mary" <madelghat...@gmail.com>
Date: Sun, 18 Mar 2007 10:49:07 -0700
Local: Sun, Mar 18 2007 1:49 pm
Subject: Re: Search feature
Thank you for replying me
I tried 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))
but it gave me error
Exception Type:         NameError
Exception Value:        global name 'Q' is not defined
If you can help me and tell what is the right syntax i ould really
appreciate that a lot

Thank you in advance
Mary Adel

On Feb 23, 1:37 pm, "Aidas Bendoraitis" <aidas.bendorai...@gmail.com>
wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
doug.napoleone@gmail.com  
View profile  
 More options Mar 18 2007, 8:52 pm
From: "doug.napole...@gmail.com" <doug.napole...@gmail.com>
Date: Mon, 19 Mar 2007 00:52:17 -0000
Local: Sun, Mar 18 2007 8:52 pm
Subject: Re: Search feature
> Exception Type:         NameError
> Exception Value:        global name 'Q' is not defined

You are missing:

from django.db.models import Q


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
lbolognini@gmail.com  
View profile  
 More options Mar 19 2007, 8:50 am
From: "lbologn...@gmail.com" <lbologn...@gmail.com>
Date: Mon, 19 Mar 2007 12:50:09 -0000
Local: Mon, Mar 19 2007 8:50 am
Subject: Re: Search feature
On Feb 22, 11:07 pm, "Mary" <madelghat...@gmail.com> wrote:

> How can i add a search feature to my website?

> Can anybody help me in this

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.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mary  
View profile  
 More options Mar 20 2007, 12:56 pm
From: "Mary" <madelghat...@gmail.com>
Date: Tue, 20 Mar 2007 16:56:01 -0000
Local: Tues, Mar 20 2007 12:56 pm
Subject: Re: Search feature
Thanks for all the tips
I just want to know how the return result template will look like
So if any body can give me a small example i would really appretiate

Thank you in advance --
Mary Adel
:(

On Mar 19, 2:50 pm, "lbologn...@gmail.com" <lbologn...@gmail.com>
wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Derek Hoy  
View profile  
 More options Mar 21 2007, 6:09 pm
From: "Derek Hoy" <derek....@gmail.com>
Date: Wed, 21 Mar 2007 22:09:58 +0000
Local: Wed, Mar 21 2007 6:09 pm
Subject: Re: Search feature
Another option for search is to use the google co-op thing- look in
your google services.  If your site is public, then it could be all
you need.

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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google