I would like to filter a JSONField my_fieldwhere the JSon is not empty. In the documentation there are has_keyand has_any_key methods but I don't know the possible keys in advance. In SQL it should be something like:
select * from my_model where cardinality(my_field)>0;
Found a way to achieve using iexact:
MyObject.objects.filter(my_field__iexact="{}")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With