How to configure Postgres extension?

In the latest version of Django (1.8), several model fields were added to take advantage of Postgres data types. I'm interested in HStoreField , and the documentation suggests installing a PG extension to use the new HStoreFieldin models.

How can I use this class HStoreExtensionto perform database expansion?

+4
source share
1 answer

HStoreField docs ask you to install the extension by adding a hyphen.

You can create an empty migration using the command

./manage.py makemigrations yourapp --empty

In the created migration file, you can import the extension,

django.contrib.postgres.operations import HStoreExtension

and add it to the list of operations.

operations = [
    HStoreExtension(),
]

, HStoreField .

. , postgres Django. : HStoreExtension() UnaccentExtension.

+4

All Articles