Skip to main content

A flexible quering JSONField and associated form field to store validated JSON in your model.

Project description


``django-json-field2`` is a flexible quering JSONField and associated form field

It is a compilation and adaptation of the following projects


Feature Description
South support
Form field
Form widget
Model field
Python3 support

``django-jsonfield2`` is also compatible with South, Django 1.8 and Python 3.


Install from PyPI:

``pip install django-jsonfield2``


``git clone git://``


Add ``jsonfield2`` to your ``PYTHONPATH`` and ``INSTALLED_APPS`` setting:






from django.db import models
from jsonfield2 import JSONField, JSONAwareManager

class JsonModel(models.Model):
code = models.CharField( blank=False, null=False, max_length=20 )
status = models.CharField( blank=True, null=True, max_length=20 )

info = JSONField(default={})

objects = JSONAwareManager(json_fields = ['info'])

def __str__(self):
return self.code

Json Query


obj = Person.objects.create(name = "Bill") = {
'sex': 'male',
'address': {
'country', 'Canada',
Person.objects.filter(info__address__country = 'Canada')
>>> [Person: "Bill"]


Now, it will validate the JSON on entry, and store it as a text in the database. When you instantiate/fetch the object, it will be turned back into a python list/dict/string.

jsonify templatetag
This allows you to convert a python data structure into JSON within a template::

{% load jsonify %}

var foo = {{ bar|jsonify }};




Allow order_by when json criteria are used


``django-jsonfield2`` is licensed under the New BSD license.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-jsonfield2-15.06.08.tar.gz (11.1 kB view hashes)

Uploaded source

Built Distribution

django_jsonfield2-15.06.08-py3.4.egg (30.4 kB view hashes)

Uploaded 3 4

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page