I want to make a filter with 2 fields from the django user model first_name and last_name like this:
queryset = User.objects.annotate(search_name=Concat('first_name', Value(' '), 'last_name'))
queryset.filter(search_name__icontains='Prueba Pruebita')
But it is not returning the filter if not the entire list of users.
This is my serializer that just brings up most of the fields and the write-only password.
class UserSerializer(serializers.ModelSerializer):
class Meta:
model = User
fields = ('id','username', 'password', 'first_name', 'last_name', 'email', 'code', 'phone')
extra_kwargs = {'password': {'write_only': True}}
Am I missing something? or is there another way to make a filter with 2 fields of a model?
Somehow it works like this:
I hope it helps someone. :)