3👍
If you want to check value of particular key in every object if it contains ‘te’, you can do:
Model.objects.filter(hstoreattr__your_key__icontains='te')
If you want to check if any key in your hstore field contains ‘te’, you will need to create your own lookup in django, because by default django won’t do such thing. Refer to custom lookups in django docs for more info.
0👍
As far as I can remember, you cannot filter in values. If you want to filter in values, you have to pass a column and value you are referencing to. When you want it to be case insensitive use __icontains
.
Although you cannot filter by all values, you can filter by all keys. Just like you showed in your code.
If you want to search for ‘text’ in all objects in key named let’s say ‘fo’ – just do smth like this:
Model.objects.filter(hstoreattr__icontains={'fo': 'text'})
- [Django]-Auto Update Django Model based on other model fields
- [Django]-How does Django determine if an uploaded image is valid?
- [Django]-Django get query execution time