Django 1.8 HStore字段抛出编程错误

bli*_*uck 5 python database postgresql psycopg2 django-1.8

我正在遵循文档中的代码

from django.contrib.postgres.fields import HStoreField
from django.db import models

class Dog(models.Model):
    name = models.CharField(max_length=200)
    data = HStoreField()

    def __str__(self):  # __unicode__ on Python 2
        return self.name
Run Code Online (Sandbox Code Playgroud)

运行此代码会导致:

ProgrammingError: can't adapt type 'dict'
Run Code Online (Sandbox Code Playgroud)

我正在使用Postgres == 9.3.6,psycopg2 == 2.6,我已经检查过HStore扩展已启用.

Tim*_*ham 23

确保添加'django.contrib.postgres'settings.INSTALLED_APPS.

  • 我做到了,但我仍然得到错误. (2认同)