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, 2010 at 12:13 AM, Michael P. Soulier <msoulier@digitaltorque.ca> wrote:
On 22/07/10 Matias said:Assuming that full_name is a property in your model, then
> 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?
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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iD8DBQFMSQi9KGqCc1vIvggRAlcOAJ9IwI6CvXE6UePEYtGEgOHa/sRAuQCggvW0
ZJXeZ7WmLHiotQTBKsA+5FU=
=MFTP
-----END PGP SIGNATURE-----
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment