Django query set filter over relationship with concat -


i filter users based on concat(first_name, last_name) accessible on userprofile.

if user.profile.first_name + ' ' +  user.profile.last_name query 

all have user.objects.all()

i tried stuff extra(), complexquery,annotation() none of them working...

any ideas how it?

here go:

from django.contrib.auth.models import user django.db.models import value, func, f, charfield  user.objects.annotate(full_name=func(f('first_name'), value(' '), f('last_name'), function='concat', output_field=charfield())).filter(full_name__icontains='dusan plavak') 

update #1:

user.objects.annotate(full_name=func(f('profile__first_name'), value(' '), f('profile__last_name'), function='concat', output_field=charfield())).filter(full_name__icontains='dusan plavak') 

Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -