2👍
✅
HStoreField
is just mapping string to string and does not support nested structure, you can use rather JSONField
which come as built-in Posgres Field in Django 1.9+ and posgres 9.4+.
models.py:
from django.db import models
from django.contrib.postgres.fields.jsonb import JSONField
class MyModel(models.Model):
...
data = JSONField(blank=True, null=True, default=dict)
views.py:
MyModel.objects.filter(data__k3__contains={'nested_k': 'nested_v'})
👤Dhia
Source:stackexchange.com