﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
23776	HStoreField example doesn't work	vedgar	nobody	"From https://docs.djangoproject.com/en/dev/ref/contrib/postgres/fields/#querying-hstorefield

With given model (Dog), in shell,

    {{{
    >>> from atest.models import Dog
    >>> Dog.objects.create(name='Rufus', data={'breed': 'labrador'})
    }}}

gives ""can't adapt type 'dict'"" error. After researching, it seems to me it's because noone called psycopg2.extras.register_hstore, that must be called to enable storing dict as hstore in a Postgres database. (If django_hstore is in the list of INSTALLED_APPS, it will call register_hstore by itself, which is probably why it works for some people. But once you remove django_hstore from INSTALLED_APPS, you'll see the bug. Since django_hstore is external app, Django probably shouldn't rely on it.)

I'm not quite sure how to fix it, since I don't know who should be responsible for registering hstore... there is a HStoreExtension operation that does it when migrating, but I have a feeling it should be inserted automatically from makemigrations (when app uses hstore), not shift the burden on users. Even if users are expected to register hstore manually, it should be clearly stated in the docs."	Bug	closed	Documentation	dev	Normal	worksforme	postgres hstore register		Unreviewed	0	0	0	0	0	0
