設定 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(),
...
]