Re: Query Set to search for a combination of model fields?

2012-03-16 Thread Guillaume Chorn
Shawn, man thanks! I actually had no idea about the pipe vs. ampersand distinction. I went ahead and changed my code to the following: def search(request): query = request.GET.get('q','') querywords = query.split(' ') lname='' for word in querywords[1:-1]: lname +=

Re: Query Set to search for a combination of model fields?

2012-03-16 Thread Matthias Kestenholz
On Fri, Mar 16, 2012 at 04:29, Shawn Milochik wrote: > Look at how the Q objects are being used in the example and it's clear why > that is. It's using the pipe (|) to do an "or" query. > > If you want to change how the search works you'll have to add more code: > > 1. Split

Re: Query Set to search for a combination of model fields?

2012-03-15 Thread Shawn Milochik
Look at how the Q objects are being used in the example and it's clear why that is. It's using the pipe (|) to do an "or" query. If you want to change how the search works you'll have to add more code: 1. Split the search parameters on whitespace. 2. Create Q objects for searching in either or

Query Set to search for a combination of model fields?

2012-03-15 Thread Gchorn
Hello All, As a learning project, I am currently putting together a site to track all of the teams and players in the NBA along with their basic statistics and information. My two models so far are, as you might expect, players and teams. For the player model, I have separate database fields