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)
- Upgrade pip on mac to install a Django library?
- Django migration error, trying to clean up date field with bad default
- Django – change form field to readonly when value in view is set to any value
- How call this backend coding?
- How do I create a many to many relationship with an existing record?
Source:stackexchange.com