# JSONField in PostgreSQL varchar limit 256

**URL:** <https://forum.djangoproject.com/t/jsonfield-in-postgresql-varchar-limit-256/5962>\
**Category:** Using Django\
**Created:** [January 3, 2021, 6:11pm UTC](https://forum.djangoproject.com/t/jsonfield-in-postgresql-varchar-limit-256/5962 "2021-01-03T18:11:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![guyko81](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/guyko81/32/3008_2.png) [@guyko81](https://forum.djangoproject.com/u/guyko81)\
**Post date:** [January 3, 2021, 6:11pm UTC](https://forum.djangoproject.com/t/jsonfield-in-postgresql-varchar-limit-256/5962/1 "2021-01-03T18:11:04Z")

</div>

Hi All,

I’ve been searching for solution for a while now and can’t find a way to change the default length of the JSONField in PostgreSQL. I know it’s stored as VarChar (checked it in the database) and the length is 256. I guess this is some default value somewhere (PostgreSQL or Django CharField?).  
I did a workaround now and just defined my field as CharField with set\_ and get\_ also defined in the model, but it’s not elegant.

Do I miss something in JSONField?

Thanks folks!  
Gabor

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [January 3, 2021, 7:16pm UTC](https://forum.djangoproject.com/t/jsonfield-in-postgresql-varchar-limit-256/5962/2 "2021-01-03T19:16:31Z")

</div>

That must be an artifact of an older database or migration. The current versions of PostgreSQL stores a [JSONField](https://docs.djangoproject.com/en/3.1/ref/models/fields/#jsonfield) as a JSONB field type.

---

<div class="post-metadata">

**Author:** ![guyko81](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/guyko81/32/3008_2.png) [@guyko81](https://forum.djangoproject.com/u/guyko81)\
**Post date:** [January 3, 2021, 8:08pm UTC](https://forum.djangoproject.com/t/jsonfield-in-postgresql-varchar-limit-256/5962/3 "2021-01-03T20:08:33Z")

</div>

I have started with a new database, PostgreSQL 13, and erased all the migration files in Django before makemigration and migrate.  
But maybe I did an initial migration before, with the CharField solution and then the field type has not changed in PostgreSQL after new migration requests (even with no migration files in Django)

I will try and delete all the tables again and see what happens.

---

<div class="post-metadata">

**Author:** ![guyko81](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/guyko81/32/3008_2.png) [@guyko81](https://forum.djangoproject.com/u/guyko81)\
**Post date:** [January 3, 2021, 11:56pm UTC](https://forum.djangoproject.com/t/jsonfield-in-postgresql-varchar-limit-256/5962/4 "2021-01-03T23:56:36Z")

</div>

When I start from an empty database Django creates JSONB field type indeed. Unfortunately the migration doesn’t change it. Can we report it somewhere?

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [January 4, 2021, 12:15am UTC](https://forum.djangoproject.com/t/jsonfield-in-postgresql-varchar-limit-256/5962/5 "2021-01-04T00:15:34Z")

</div>

What do you mean by “the migration doesn’t change it”? A lot depends upon what was done from the very beginning and how migrations were handled along the way. Are you saying that this was originally a VarChar field and then changed to a JSON Field?

If you don’t have a continuous and uninterrupted chain of migration files from initial table creation to present, I don’t think there’s anything to report. (On the other hand, if you’ve got such a chain that shows that field was originally a CharField, then subsequently changed to a JSONField and no ALTER TABLE was generated, that might be worth reporting.)
