{ "info": { "author": "Johnny Chang", "author_email": "hiimdoublej.pi@gmail.com", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Framework :: Django", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.6" ], "description": "# django-json-ld\n\nThis is a django template tag to help developers render [structured data](https://developers.google.com/search/docs/guides/intro-structured-data) tags inside their django templates.\n\nFurthermore a collection of views and mixins are included:\n * `JsonLdContextMixin`, `JsonLdView`\n * `JsonLdSingleObjectMixin`, `JsonLdDetailView`\n\n## Installation\nInstall using `pip`:\n```\npip install django-json-ld\n```\n\nAdd `django_json_ld` to `INSTALLED_APPS` in `settings.py`:\n```\nINSTALLED_APPS = [\n # Other apps...\n 'django_json_ld',\n]\n```\n\n## Settings\nYou can override the following options in settings.py:\n\n`JSON_LD_CONTEXT_ATTRIBUTE`: the context attribute name used in `django_json_ld`'s Class-Based Views (CBV). Defaults to `'sd'`.\n\n`JSON_LD_MODEL_ATTRIBUTE`: the model attribute name used by `JsonLdDetailView` to get the model's structured data. Defaults to `'sd'`.\n\n`JSON_LD_DEFAULT_CONTEXT`: default json-ld context when using `django_json_ld`'s CBVs. Defaults to `'https://schema.org'`.\n\n`JSON_LD_DEFAULT_TYPE`: default json-ld type when using `django_json_ld`'s CBVs. Defaults to `'Thing'`.\n\n`JSON_LD_GENERATE_URL`: generate json-ld's `url` field when using `django_json_ld`'s CBVs. Defaults to `True`.\n\n`JSON_LD_EMPTY_INPUT_RENDERING`: behavior when the template tag receives an empty object. Possible values:\n* `strict` default, raise TemplateSyntaxError.\n* `silent` renders nothing.\n* `generate_thing` creates object with URL of current page. eg: \n```\nstructured_data = {\n \"@context\": ,\n \"@type\": ,\n \"url\": ,\n }\n```\n\n\n## Usage Example\nAssuming you have a structured data `sd` like the following in your context (copied from the link above).\n```\nsd = {\n \"@context\": \"https://schema.org\",\n \"@type\": \"Organization\",\n \"url\": \"http://www.example.com\",\n \"name\": \"Unlimited Ball Bearings Corp.\",\n \"contactPoint\": {\n \"@type\": \"ContactPoint\",\n \"telephone\": \"+1-401-555-1212\",\n \"contactType\": \"Customer service\"\n }\n}\n```\nThen, in your template:\n```\n{% load render_json_ld from django_json_ld %}\n{% render_json_ld sd %}\n```\nWould render into:\n```\n\n```\n\n### Class-Based View example\n\n#### Simple View\n\nviews.py\n```python\nfrom django_json_ld.views import JsonLdContextMixin\n\nclass HomeView(JsonLdContextMixin, generic.ListView):\n structured_data = {\n \"@type\": \"Organization\",\n \"name\": \"The Company\",\n \"description\": _(\"A great company.\"),\n }\n\n def get_structured_data(self):\n structured_data = super(HomeView, self).get_structured_data()\n structured_data[\"event\"] = get_next_event()\n return structured_data\n```\n\nBy using `{% render_json_ld sd %}`, as explained in the previous example, would render into something like:\n\n```json\n{\n \"@context\":\"https://schema.org\", \n \"@type\":\"Organization\",\n \"name\":\"The Company\",\n \"description\":\"Uma grande empresa.\",\n \"url\":\"http://example.org/\",\n \"event\": {\n \"@type\": \"Event\",\n \"about\": [\"Hodler\",\"Monet\",\"Munch\"],\n \"name\": \"Peindre l'impossible\",\n \"startDate\": \"2016-09-15\",\n \"endDate\": \"2017-01-22\"\n }\n}\n```\n\nIn the above example `JsonLdContextMixin` adds `sd` to `HomeView`'s context. \n`django_json_ld` supports lazy translations, hence `\"description\"` showing the translated version of its original value.\n\n#### Detail View\n\nviews.py\n```python\nfrom django_json_ld.views import JsonLdDetailView\n\nclass ProductDetailView(JsonLdDetailView):\n model=Product\n```\n\nmodels.py\n```python\nclass Product(models.Model):\n name = models.CharField(_('Name'), max_length=255)\n description = models.TextField(_('Description'))\n\n @property\n def sd(self):\n return {\n \"@type\": 'Product',\n \"description\": self.description,\n \"name\": self.name,\n }\n```\n\nBy using `{% render_json_ld sd %}`, as explained previously, would render into something like:\n\n```json\n{\n \"@context\":\"https://schema.org\", \n \"@type\":\"Product\",\n \"name\":\"The Product\",\n \"description\":\"A great product.\",\n \"url\":\"http://example.org/products/1/the-product/\"\n}\n```\n\nIn the above example `JsonLdDetailView` adds `sd` to `ProductDetailView`'s context, using `Product`'s own `sd` property. The `url` is generated automatically by `JsonLdDetailView`. This behaviour is configurable through settings.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/hiimdoublej/django-json-ld", "keywords": "django,webpack,assets", "license": "", "maintainer": "", "maintainer_email": "", "name": "django-json-ld", "package_url": "https://pypi.org/project/django-json-ld/", "platform": "", "project_url": "https://pypi.org/project/django-json-ld/", "project_urls": { "Homepage": "https://github.com/hiimdoublej/django-json-ld" }, "release_url": "https://pypi.org/project/django-json-ld/0.0.4/", "requires_dist": null, "requires_python": "", "summary": "Django template tag for json-ld", "version": "0.0.4" }, "last_serial": 4939248, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "bb54072eaba49c379de3e2d0b6747498", "sha256": "0d5e93ea09d7b9c30956bac8aa14a9d67c713345a8ed4c99210b819bb996a49d" }, "downloads": -1, "filename": "django_json_ld-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "bb54072eaba49c379de3e2d0b6747498", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 3431, "upload_time": "2019-01-15T08:13:24", "url": "https://files.pythonhosted.org/packages/d2/67/bc2ace16a58f954d354b7487e524f87a57602d5798a00dd0b9aaa758e9bb/django_json_ld-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f9c713abd9538d560168c5aa176a00ea", "sha256": "9d27b5c64e5d90e30308633bda6c4985d3ec28c53166b39e03437e73b0734a66" }, "downloads": -1, "filename": "django-json-ld-0.0.1.tar.gz", "has_sig": false, "md5_digest": "f9c713abd9538d560168c5aa176a00ea", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2208, "upload_time": "2019-01-15T08:13:26", "url": "https://files.pythonhosted.org/packages/c9/5d/3ae6fe27b831616bc55ee63dc89227557a625401220b058ed1c562553105/django-json-ld-0.0.1.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "de4514915cc1c0829f00627353561d41", "sha256": "9cd01de353c0f2941b2bcbfe6ec998979695662d92fad667b764d51547bf6cdf" }, "downloads": -1, "filename": "django_json_ld-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "de4514915cc1c0829f00627353561d41", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5159, "upload_time": "2019-03-11T03:42:58", "url": "https://files.pythonhosted.org/packages/15/61/3c32c8593ce0dcc540a8f3aa8a5365c95072c2e8108088a9c8570d68068d/django_json_ld-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2042b7676a57eaaf62a4df490250e156", "sha256": "02574c8e5ea18f5c871cbca14c6ead675a58abac806274a8a49f642c74fbe827" }, "downloads": -1, "filename": "django-json-ld-0.0.3.tar.gz", "has_sig": false, "md5_digest": "2042b7676a57eaaf62a4df490250e156", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3608, "upload_time": "2019-03-11T03:43:00", "url": "https://files.pythonhosted.org/packages/61/af/e9785f68cc8c5fde13c739d95aacb67e0d948716848930f63a4fdcb743c9/django-json-ld-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "d149f0776fc004d04ba5598e059c8e28", "sha256": "8b67ce8b1254d006c8534b7d27535122c19425c259b26c530bc9691bf087d925" }, "downloads": -1, "filename": "django_json_ld-0.0.4-py3-none-any.whl", "has_sig": false, "md5_digest": "d149f0776fc004d04ba5598e059c8e28", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7269, "upload_time": "2019-03-14T11:53:31", "url": "https://files.pythonhosted.org/packages/4b/3e/8997880d0a76f9631a28b616a445dcc236790198d40ce75c5ddfc99d3a5a/django_json_ld-0.0.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e72b49300dfcdffd727949f946cd8d62", "sha256": "183d6ffe0758effbec7cfa3f10c8bff22ed0524123aed956d16a200deff4849f" }, "downloads": -1, "filename": "django-json-ld-0.0.4.tar.gz", "has_sig": false, "md5_digest": "e72b49300dfcdffd727949f946cd8d62", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5389, "upload_time": "2019-03-14T11:53:33", "url": "https://files.pythonhosted.org/packages/3b/53/dd4baf2a71aa25ccc28d90f8bf680670850653bf728170063133585ee340/django-json-ld-0.0.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d149f0776fc004d04ba5598e059c8e28", "sha256": "8b67ce8b1254d006c8534b7d27535122c19425c259b26c530bc9691bf087d925" }, "downloads": -1, "filename": "django_json_ld-0.0.4-py3-none-any.whl", "has_sig": false, "md5_digest": "d149f0776fc004d04ba5598e059c8e28", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7269, "upload_time": "2019-03-14T11:53:31", "url": "https://files.pythonhosted.org/packages/4b/3e/8997880d0a76f9631a28b616a445dcc236790198d40ce75c5ddfc99d3a5a/django_json_ld-0.0.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e72b49300dfcdffd727949f946cd8d62", "sha256": "183d6ffe0758effbec7cfa3f10c8bff22ed0524123aed956d16a200deff4849f" }, "downloads": -1, "filename": "django-json-ld-0.0.4.tar.gz", "has_sig": false, "md5_digest": "e72b49300dfcdffd727949f946cd8d62", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5389, "upload_time": "2019-03-14T11:53:33", "url": "https://files.pythonhosted.org/packages/3b/53/dd4baf2a71aa25ccc28d90f8bf680670850653bf728170063133585ee340/django-json-ld-0.0.4.tar.gz" } ] }