﻿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
26584	HStoreField reading broken from  external script or console.	Dario Deledda	nobody	"== Bug Description==
When you run from external script or console the reading of an '''HStoreField''' return a '''String''' instead a '''Dict'''.
for example: an object from a class like:

{{{
class Alert(models.Model):
  data = HStoreField(default={})
}}}

if you try:
{{{
a=Alert.objects.all()[0
type(a.data)
}}}
return {{{<class 'str'>}}} instead {{{<class 'dict'>}}}

== Brief analysis ==
It seems that in the console or script init, the '''register_hstore''' it's not called.

== WorkAround: ==
If you use for the init of the console or external script the following code:
{{{
sys.path.append(gDjangoProjectPath)
os.environ[""DJANGO_SETTINGS_MODULE""] = gDjangoSetting
django.setup()
from django.contrib.postgres.fields import HStoreField
from wot.apps.website.alert import Alert

# HSTORE BUG WORK AROUND!!
from django.db import connection
from psycopg2.extras import register_hstore
register_hstore(connection.connection)
}}}
the '''HStoreField''' work normally.

== pip Freeze ==

{{{
aiohttp==0.21.5
arrow==0.7.0
chardet==2.3.0
defusedxml==0.4.1
Django==1.8.12
django-allauth==0.25.2
django-braces==1.8.1
django-extensions==1.6.1
django-filter==0.13.0
django-grappelli==2.8.1
django-nested-admin==3.0.2
djangorestframework==3.3.3
eventlet==0.18.4
gevent==1.1.1
greenlet==0.4.9
gunicorn==19.4.5
Markdown==2.6.6
oauthlib==1.0.3
Pillow==3.2.0
psycopg2==2.6.1
pyinotify==0.9.6
python-dateutil==2.5.3
python-monkey-business==1.0.0
python-redmine==1.5.1
python3-openid==3.0.10
pytz==2016.4
reportlab==3.3.0
requests==2.9.1
requests-oauthlib==0.6.1
setproctitle==1.1.9
six==1.10.0
stripe==1.32.2
tinycss==0.3
}}}"	Bug	new	Database layer (models, ORM)	1.8	Normal		HStoreField register_hstore		Unreviewed	0	0	0	0	0	0
