I want to make a filter with 2 fields of the user model of django first_name and last_name In this way:
queryset = User.objects.annotate(search_name=Concat('first_name', Value(' '), 'last_name'))
queryset.filter(search_name__icontains='Prueba Pruebita')
But you are not returning the filter if not the entire list of users.
This is my serializer that simply brings the most fields and the password that is only written.
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}}
Is something missing? Or is there another way to make a filter with 2 fields of a model?