Thursday, July 22, 2010

Re: filter users by full name

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 would require that every part of the name passed in is part of
the first or last name.

Shawn

--
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