﻿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
25949	Document that JSONField requires Psycopg 2.5.4+	Kevin Campbell	Tim Graham	"When using Django 1.9 with psycopg2==2.5.2 and JSONField for postgres, the field will be correctly stored as jsonb in the postgres database, but will be converted to a string when read back.

{{{#!python
from django.contrib.postgres.fields import JSONField
class TestModel(models.Model):
    data = JSONField(null=True)
}}}

{{{#!python
tm = TestModel(data=[1,2,3])
tm.save()
}}}

{{{#!sql
select * from bugtest_testmodel
 id |   data
----+-----------
  1 | [1, 2, 3]
}}}

{{{#!sql
select data->0 from bugtest_testmodel;
 ?column?
----------
 1
}}}

{{{#!python
tm = TestModel.objects.all()[0]
tm.data
'[1, 2, 3]'
}}}

The issue is resolved in the latest psycopg2 version (2.6.1). It's somewhat debatable if this is a bug, but as the behaviour does not match the Django manual I think it would be best to raise a Warning when using JSONField with older versions of psycopg2."	Cleanup/optimization	closed	Documentation	1.9	Normal	fixed			Accepted	1	0	0	0	0	0
