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
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,
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?
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)
>
>
>
>
>
>
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
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
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
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
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
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
10 matches
Mail list logo