DjangoJSONField - a PostgreSQL specific field


Syntax

  • JSONField(**options)

Remarks

  • Django's JSONField actually stores the data in a Postgres JSONB column, which is only available in Postgres 9.4 and later.

  • JSONField is great when you want a more flexible schema. For example if you want to change the keys without having to do any data migrations, or if not all your objects have the same structure.

  • If you're storing data with static keys, consider using multiple normal fields instead of JSONFields instead, as querying JSONField can get quite tedious sometimes.

Chaining queries

You can chain queries together. For example, if a dictionary exists inside a list, add two underscores and your dictionary query.

Don't forget to separate queries with double underscores.