Search code examples
pythondatabasepostgresqlpsycopg2django-1.8

Django 1.8 HStore field throwing Programming Error


I'm following the code in the documentation

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

Running this code results in:

ProgrammingError: can't adapt type 'dict'

I'm using Postgres==9.3.6, psycopg2==2.6, and I've checked that the HStore extension is enabled.


Solution

  • Ensure you add 'django.contrib.postgres' to settings.INSTALLED_APPS.