Thursday, July 22, 2010

Re: filter users by full name

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?

Assuming that full_name is a property in your model, then

q = User.objects.filter(full_name="John Test")

should work.

Mike
--
Michael P. Soulier <msoulier@digitaltorque.ca>
"Any intelligent fool can make things bigger and more complex... It takes a
touch of genius - and a lot of courage to move in the opposite direction."
--Albert Einstein

No comments:

Post a Comment