#26584: HStoreField reading broken from external script or console.
-------------------------------------+-------------------------------------
Reporter: penguindark | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.8
(models, ORM) | Keywords: HStoreField
Severity: Normal | register_hstore
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
== 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
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26584>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/054.c2e4421da2920ba4cd3516520717451b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.