Generic JSON model and form fields.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
json_field Version bump Sep 6, 2014
test_project Constrain date/time regex to avoid false matches Sep 6, 2014
.gitignore Init Apr 24, 2012
AUTHORS Init Apr 24, 2012
LICENSE Init Apr 24, 2012
MANIFEST Updated PyPI manifest May 16, 2012 Include AUTHORS and README.rst in source tarball. May 16, 2012
README.rst Update README.rst Jan 25, 2016 Init Apr 24, 2012 Version bump Sep 6, 2014


Django JSON Field

NOTE: This project is seeking new active maintainers.

django-json-field contains a flexible JSONField and associated form field. The model field is not only capable of serializing common JSON data types (int, float, decimal, string, time, date, datetime, etc.) but also lazily deserializing them so they can be accessed and modified as normal Python objects within Django.

A form field is also provided. It will accept serialized representations:

{"date": "2012-04-23T19:16:54.133", "num": "1.2399"}

And also provides safe access to the datetime module for explicit use:

{"date": datetime.datetime(2012, 4, 23, 19, 16, 54, 133000)}

While the JSON string will not be deserialized until it is accessed it can still be a performance concern, so you may find it valuable to disable the custom deserializer (JSONField(decoder=None)).

django-json-field is also compatible with South and Python 3.


Install from PyPI:

pip install django-json-field

If installing manually, first install the dependencies:

pip install python-dateutil six

Install from GitHub:

git clone git://

pip install -e git+git://


Add json_field to your PYTHONPATH and INSTALLED_APPS setting:


That's all!


Add a JSONField to your model like any other field.

from json_field import JSONField
from django.db import models

class MyModel(models.Model):

    json = JSONField()

JSONField also has a few additional optional parameters.

  • default: Falls back on "null" if not provided and null=False, otherwise None
  • db_type: Allows you to specify the column type (default: text)
  • lazy: Defer deserialization until the field is directly accessed (default: True)
  • encoder: Custom JSON encoder (default: DjangoJSONEncoder)
  • decoder: Custom JSON decoder (default: json_field.fields.JSONDecoder)
  • encoder_kwargs: Specify all arguments to the encoder (overrides encoder)
  • decoder_kwargs: Specify all arguments to the decoder (overrides decoder)
  • evaluate_formfield: Evaluate (risky) and enable use of the datetime module in the form field (default: False)


django-json-field is licensed under the New BSD license.