设置 HStoreField
首先,我们需要做一些设置才能让 HStoreField 正常工作。
- 确保
django.contrib.postgres在你的`INSTALLED_APPS 中 - 将
HStoreExtension添加到你的迁移中。记得在任何CreateModel或AddField迁移之前放置HStoreExtension。
from django.contrib.postgres.operations import HStoreExtension
from django.db import migrations
class FooMigration(migrations.Migration):
# put your other migration stuff here
operations = [
HStoreExtension(),
...
]