Re: filter users by full name

2010-07-23 Thread Michael P. Soulier
On 23/07/10 Santiago Perez said: > If you're using MySQL then this should work: > > models.User.objects.extra(where=["concat(first_name, ' ', last_name)=%s"], > params=["John Test"]) > > Not sure how portable the concat function is or what alternatives are there > in other backends but

Re: filter users by full name

2010-07-22 Thread Santiago Perez
If you're using MySQL then this should work: models.User.objects.extra(where=["concat(first_name, ' ', last_name)=%s"], params=["John Test"]) Not sure how portable the concat function is or what alternatives are there in other backends but shouldn't be very hard to find out. On Fri, Jul 23,

Re: filter users by full name

2010-07-22 Thread Michael P. Soulier
On 22/07/10 Matias said: > Hi, > > What is the recommended way to get all the users whose full_name matches > a given string? > > I need to do something like: > > User.objects.filter(get_full_name="John Test") > > But that doesn't seem to work. > > Is list comprehensions the only way to go?

Re: filter users by full name

2010-07-22 Thread Ryan LeTulle
actually meant the _users_ model http://docs.djangoproject.com/en/dev/topics/auth/ On Thu, Jul 22, 2010 at 4:27 PM, Ryan LeTulle wrote: > O sorry, I took it that he was just trying to match both the first and last > name in the admin model. (i.e. 2 fields) > > > > > >

Re: filter users by full name

2010-07-22 Thread Ryan LeTulle
O sorry, I took it that he was just trying to match both the first and last name in the admin model. (i.e. 2 fields) On Thu, Jul 22, 2010 at 4:24 PM, Shawn Milochik wrote: > On Thu, Jul 22, 2010 at 5:20 PM, Ryan LeTulle wrote: > > Why wouldn't you

Re: filter users by full name

2010-07-22 Thread Shawn Milochik
On Thu, Jul 22, 2010 at 5:20 PM, Ryan LeTulle wrote: > Why wouldn't you simply? > > User.objects.filter(firstname="John", lastname="Doe") > > > Because the OP wants to accept a string containing full (both first and last) name, and you can't reliably split that into "first

Re: filter users by full name

2010-07-22 Thread Shawn Milochik
To expand on what Scott said, you could do something like this: #if a name was passed if name and len(name): name_q = Q() for token in name.split(): name_q = name_q & (Q(first_name__icontains=token) | Q(last_name__icontains=token)) This

Re: filter users by full name

2010-07-22 Thread Ryan LeTulle
Why wouldn't you simply? User.objects.filter(firstname="John", lastname="Doe") On Thu, Jul 22, 2010 at 4:01 PM, Scott Gould wrote: > It won't work because there's no database column that corresponds to > the full name. > > A simple but limited alternative would be to

Re: filter users by full name

2010-07-22 Thread Scott Gould
It won't work because there's no database column that corresponds to the full name. A simple but limited alternative would be to split the string on " " and use the result as first_name and last_name, but you would probably want to take into account first_names and/or last_names with legitimate

filter users by full name

2010-07-22 Thread Matias
Hi, What is the recommended way to get all the users whose full_name matches a given string? I need to do something like: User.objects.filter(get_full_name="John Test") But that doesn't seem to work. Is list comprehensions the only way to go? -- You received this message because you are