Django JSONField - a PostgreSQL specific field

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

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.



Got any Django Question?