Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 742
blinduck Avatar asked Apr 10 '15 09:04

blinduck


2 Answers

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

like image 85
Tim Graham Avatar answered Sep 19 '22 01:09

Tim Graham


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

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

like image 37
Maximus Besman Avatar answered Sep 21 '22 01:09

Maximus Besman