{ "info": { "author": "Kevin Mickey", "author_email": "kwmickey@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Framework :: Django", "Framework :: Django :: 1.8", "Framework :: Django :: 1.9", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Natural Language :: English", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5" ], "description": "# django-prettyjson\n\n[](https://badge.fury.io/py/django-prettyjson) [](https://travis-ci.org/kevinmickey/django-prettyjson)\n\nEnables pretty JSON viewer in Django forms, admin, or templates. The viewer is adapted from [jQuery JSONView](https://github.com/yesmeck/jquery-jsonview). It is compatible with almost anything: JSON stored in a string, a jsonfield (using django.contrib.postgres or [django-jsonfield](https://github.com/bradjasper/django-jsonfield/)), or any python object that can be serialized to JSON (using [standardjson](https://github.com/audreyr/standardjson)).\n\n## Demo\n\nSee http://kevinmickey.github.io/django-prettyjson\n\n## Installation\n\nAt the command line:\n\n```sh\npip install django-prettyjson\n```\n\n## Configuration\n\nAdd `'prettyjson'` to `INSTALLED_APPS` in `settings.py`:\n\n```python\nINSTALLED_APPS = (\n ...,\n 'prettyjson',\n)\n```\n\n## Usage\n\nIn a form or admin of a model, enable a pretty JSON viewer for a particular field:\n\n```python\nfrom prettyjson import PrettyJSONWidget\n\nclass JsonForm(forms.ModelForm):\n class Meta:\n model = Test\n fields = '__all__'\n widgets = {\n 'myjsonfield': PrettyJSONWidget(),\n }\n\nclass JsonAdmin(admin.ModelAdmin):\n form = JsonForm\n```\n\nEnable pretty JSON viewer for every JSONField of a model:\n\n```python\nfrom django.contrib.postgres.fields import JSONField\n\nclass JsonAdmin(admin.ModelAdmin):\n formfield_overrides = {\n JSONField: {'widget': PrettyJSONWidget }\n }\n```\n\nIn templates, you can also enable a pretty JSON viewer. Use the `prettyjson` template tag with a string JSON or with objects (dicts, QuerySets, etc.) that can be serialized to a JSON. Note that the template tag must be loaded using `{% load prettyjson %}`. It also has CSS and JS that must be included using `{% prettyjson_setup %}`.\n\n```htmldjango\n{% extends \"base.html\" %}\n\n{% load prettyjson %}\n\n{% block header %}\n {{ block.super }}\n {% prettyjson_setup %}\n{% endblock %}\n\n{% block content %}\n {% prettyjson myqueryset %}\n {% prettyjson mydict %}\n {% prettyjson '{\"hey\": \"guy\",\"anumber\": 243,\"anobject\": {\"whoa\": \"nuts\",\"anarray\": [1,2,\"thr