Django 1.8 HStore field throwing Programming Error
Asked Answered
S

2

6

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.

Shumway answered 10/4, 2015 at 9:22 Comment(0)
E
30

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

Evaporimeter answered 10/4, 2015 at 16:28 Comment(0)
B
1

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

And the order is important! Put it over the other django.contrib APPS

Boost answered 11/11, 2020 at 21:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.