[Fixed]-Filter on calculated representation of some fields

1👍

After a lot of experimenting, I managed to do it using a Func:

class LocationLabel(Func):
    function = 'CONCAT'
    template = '%(function)s(RIGHT(CONCAT(\'00\',%(expressions)s),2))'
    arg_joiner = '),2), RIGHT(CONCAT(\'00\','

models.Location.object.
   annotate(locationlabel=
        LocationLabel('aisle','rack','plank', output_field=CharField())
   ).
   filter(locationlabel__icontains=query)

0👍

You cannot perform a filter on a property, it has to be on fields.
In this case i think this will do what you require because unicode is just a formatted form actual integer value in fields:

Location.objects.filter(aisle=1, rack=1)

Leave a comment