{
"info": {
"author": "fusionbox, inc.",
"author_email": "programmers@fusionbox.com",
"bugtrack_url": null,
"classifiers": [
"Development Status :: 5 - Production/Stable",
"Framework :: Django",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Software Development :: Libraries"
],
"description": "===============\ndjango-json-tag\n===============\n\n.. image:: https://api.travis-ci.org/graingert/django-json-tag.png\n :alt: Building Status\n :target: https://travis-ci.org/graingert/django-json-tag\n\n\nA lightweight collection of JSON helpers for Django. Includes a template filter\nfor safely outputting JSON, views that encode and decode JSON, and a helper for\nwriting simple REST views.\n\nA special JSON encoder is used to serialize QuerySets and objects with\n``to_json`` methods.\n\n------\nFilter\n------\n\nYou can serialize an object in JSON using the ``|json`` filter. This is useful\nto generate safe JavaScript:\n\n.. code:: html\n\n {% load json_tag %}\n \n\n``|json`` is safe to use anywhere in XML or XHTML except in a double quoted attribute. It's\nimportant to use this tag rather than dumping the output of ``json.dumps`` into\nHTML, because an attacker could output a closing tag and effect an XSS attack.\nFor example, if we output ``json.dumps(\"\n\nWe get:\n\n.. code:: html\n\n \n \n\nThis allows the attacker to inject their own JavaScript. The ``|json`` tag\nprevents this by encoding the closing ```` tag with JSON's unicode\nescapes. If we output ``{{ somedata|json }}``, we get:\n\n.. code:: html\n\n \n\njson_tag also escapes single quotes this allows you to write valid JS for tools like\neslint-plugin-html and for use in single quoted XML or XHTML attributes:\n\n.. code:: html\n\n \n\nIt also escapes ampersands in order to generate valid XML. For example, with the value\n``foo & bar``:\n\n.. code:: xml\n\n {{ value|json }}\n \n\n---\nTag\n---\n\nYou can also serialize multiple objects at the same time with the `{% json %}`\ntemplate tag.\n\nTo create an Array, use:\n\n.. code:: html\n\n {% load json_tag %}\n \n\nTo create an Object, use:\n\n.. code:: html\n\n {% load json_tag %}\n \n\nIf you mix args and kwargs, however, you get an array-like object with\nnumeric properties from the args and string properties from the kwargs.\n\n.. code:: html\n\n {% load json_tag %}\n \n\n\nThe `length` property is populated from the number of args passed to\nallow use with Array methods like Array.prototype.map or Array.from.\nYou can override it, but it is likely to cause Array methods to fail:\n\n.. code:: html\n\n {% load json_tag %}\n \n\n-----\nViews\n-----\n\n``JsonResponseMixin``\n=====================\n\n``JsonResponseMixin`` implements ``render_to_response`` method that serializes\nan object into a JSON response. Thus it is compatible with generic Django\nviews:\n\n.. code:: python\n\n from django.db import models\n from django.views.generic.detail import BaseDetailView\n from json_tag.views import JsonResponseMixin\n\n class Blog(models.Model):\n title = models.CharField(max_length=255)\n body = models.TextField()\n\n def to_json(self):\n return {\n 'title': self.title,\n 'body': self.body,\n }\n\n class BlogDetailView(JsonResponseMixin, BaseDetailView):\n \"\"\"\n Detail view returning object serialized in JSON\n \"\"\"\n model = Blog\n\n\n``JsonRequestMixin``\n====================\n\n``JsonRequestMixin`` gives access to the request data through ``data()`` method.\n\n.. code:: python\n\n from django.views.generic.base import View\n from json_tag.views import JsonRequestMixin:\n from json_tag.http import JsonResponse\n\n class EchoView(JsonRequestMixin, View):\n def dispatch(self, *args, **kwargs):\n return JsonResponse(self.data())\n\n\n``RestView``\n============\n\n``RestView`` is an abstract class. Subclasses should implement `auth()`, for\nhandling authentication, and at least one HTTP method.\n\n``RestView`` implements `OPTIONS` http method, and inherits from\n``JsonRequestMixin`` and ``JsonResponseMixin``.\n\n.. code:: python\n\n from django.core.exceptions import PermissionDenied\n from json_tag.views import RestView\n from .utils import get_action\n\n class CrazyRestView(RestView):\n def auth(self, *args, **kwargs):\n if not self.request.user.is_superuser:\n raise PermissionDenied\n\n def post(self, *args, **kwargs):\n action = kwargs.pop('action')\n action_func = get_action(action)\n return self.render_to_response(action_func(self.data()))\n\n\nChangelog\n=========\n\n0.0.1 (2018-04-24)\n------------------\n\n- Rename module to json_tag\n\n\n0.0.0 (2018-04-24)\n------------------\n\nInitial release:\n\n- Extracted from django-argonauts\n- `{% json %}` tag\n- escape single quote\n- fix travis tests",
"description_content_type": "",
"docs_url": null,
"download_url": "",
"downloads": {
"last_day": -1,
"last_month": -1,
"last_week": -1
},
"home_page": "https://github.com/graingert/django-json-tag",
"keywords": "rest json views django helpers",
"license": "",
"maintainer": "Thomas Grainger",
"maintainer_email": "django-json-tag@graingert.co.uk",
"name": "django-json-tag",
"package_url": "https://pypi.org/project/django-json-tag/",
"platform": "",
"project_url": "https://pypi.org/project/django-json-tag/",
"project_urls": {
"Homepage": "https://github.com/graingert/django-json-tag"
},
"release_url": "https://pypi.org/project/django-json-tag/0.0.1/",
"requires_dist": null,
"requires_python": "",
"summary": "A lightweight collection of JSON helpers for Django.",
"version": "0.0.1"
},
"last_serial": 3802129,
"releases": {
"0.0.0": [
{
"comment_text": "",
"digests": {
"md5": "0ad63d26142c5f76e2182e8ce8f049d3",
"sha256": "deefc405964247161cd34b65e3d58becc076811a2066256dadccb7733759c57c"
},
"downloads": -1,
"filename": "django_json_tag-0.0.0-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "0ad63d26142c5f76e2182e8ce8f049d3",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 12597,
"upload_time": "2018-04-24T09:19:36",
"url": "https://files.pythonhosted.org/packages/7c/de/2efe06827ce187da59b7eb42f82ac0026de51b371d72b265d2a5aaa8eb1c/django_json_tag-0.0.0-py2.py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "4bfa8c0692ed8094acb3742c6cf406d7",
"sha256": "8b33cda8efb1ee3625098e01805c0427b47502107af16a96d56cf340fc3bfb77"
},
"downloads": -1,
"filename": "django-json-tag-0.0.0.tar.gz",
"has_sig": false,
"md5_digest": "4bfa8c0692ed8094acb3742c6cf406d7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 9746,
"upload_time": "2018-04-24T09:19:37",
"url": "https://files.pythonhosted.org/packages/38/4f/bffd58f497dedad76bbb71e230126aa8a9c5bb01321af94123b052c88353/django-json-tag-0.0.0.tar.gz"
}
],
"0.0.1": [
{
"comment_text": "",
"digests": {
"md5": "8127d263a7a13b8c90f4ec5ac761710d",
"sha256": "dd271c24889b9493cb31ac8cfdc657a7d595d61a99fb4e6ceb4123a5e80ea118"
},
"downloads": -1,
"filename": "django_json_tag-0.0.1-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "8127d263a7a13b8c90f4ec5ac761710d",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 12591,
"upload_time": "2018-04-24T10:08:41",
"url": "https://files.pythonhosted.org/packages/d0/c1/ebe801765a3003cda1dd40c507de968c6c4e467cb20c9830c8d16b9a1413/django_json_tag-0.0.1-py2.py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "dbc8a50f2a5a30f55b7e52dbc4b51245",
"sha256": "8bda42214143415409e41777e6187ab6faee655fe046cdd0363c9f03d923305f"
},
"downloads": -1,
"filename": "django-json-tag-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "dbc8a50f2a5a30f55b7e52dbc4b51245",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 9619,
"upload_time": "2018-04-24T10:08:40",
"url": "https://files.pythonhosted.org/packages/8c/aa/ed44baf40aac58a6897f2eb4989a29541159e32548aaf560e8ca4a2aa704/django-json-tag-0.0.1.tar.gz"
}
]
},
"urls": [
{
"comment_text": "",
"digests": {
"md5": "8127d263a7a13b8c90f4ec5ac761710d",
"sha256": "dd271c24889b9493cb31ac8cfdc657a7d595d61a99fb4e6ceb4123a5e80ea118"
},
"downloads": -1,
"filename": "django_json_tag-0.0.1-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "8127d263a7a13b8c90f4ec5ac761710d",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 12591,
"upload_time": "2018-04-24T10:08:41",
"url": "https://files.pythonhosted.org/packages/d0/c1/ebe801765a3003cda1dd40c507de968c6c4e467cb20c9830c8d16b9a1413/django_json_tag-0.0.1-py2.py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "dbc8a50f2a5a30f55b7e52dbc4b51245",
"sha256": "8bda42214143415409e41777e6187ab6faee655fe046cdd0363c9f03d923305f"
},
"downloads": -1,
"filename": "django-json-tag-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "dbc8a50f2a5a30f55b7e52dbc4b51245",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 9619,
"upload_time": "2018-04-24T10:08:40",
"url": "https://files.pythonhosted.org/packages/8c/aa/ed44baf40aac58a6897f2eb4989a29541159e32548aaf560e8ca4a2aa704/django-json-tag-0.0.1.tar.gz"
}
]
}