Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSONField is represented in Postgres 9.4 as Text #140

Closed
ferasodh opened this issue Sep 29, 2015 · 4 comments
Closed

JSONField is represented in Postgres 9.4 as Text #140

ferasodh opened this issue Sep 29, 2015 · 4 comments

Comments

@ferasodh
Copy link

Hi,

I'm trying to use your library to get json type support in django. Here is my model:

class Classifier(models.Model):
     name = models.CharField(max_length=50)
     attributes = JSONField()

and here is database table:

   Column   |         Type          |                             Modifiers                              | Storage  | Stats target | Description 
------------+-----------------------+--------------------------------------------------------------------+----------+--------------+-------------
 id         | integer               | not null default nextval('classifier_classifier_id_seq'::regclass) | plain    |              | 
 name       | character varying(50) | not null                                                           | extended |              | 
 attributes | text                  | not null                                                           | extended |              | 

Why is attributes type is text? shouldn't it be json?

Thanks,
Feras

@jangnezda
Copy link

Hi, looks like the support for Postgres 'json' column type has been removed somewhere around version 1.0. More information here: #57
If you need this, you'll have to use 0.9.x version of jsonfield package.

@dmkoch
Copy link
Collaborator

dmkoch commented Mar 2, 2017

If you want the underlying column type to be json (jsonb actually) and you're using PostgreSQL >= 9.4, then your best bet is to use the native JSONField included in Django >= 1.9

https://docs.djangoproject.com/en/1.10/ref/contrib/postgres/fields/#jsonfield

This module is still useful if you need to support JSON in databases other than Postgres or are creating a third party module that needs to be database agnostic.

But if you're an end user using Postgres and want full-featured JSON support, use JSONField from Django.

@dmkoch dmkoch closed this as completed Mar 2, 2017
@xlotlu
Copy link

xlotlu commented Mar 9, 2017

This module is still useful if you need to support JSON in databases other than Postgres or are creating a third party module that needs to be database agnostic.

But if you're an end user using Postgres and want full-featured JSON support, use JSONField from Django.

This should make it into the documentation.

@dmkoch
Copy link
Collaborator

dmkoch commented Mar 9, 2017

Good idea -- I added to the README.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants