Skip to main content

A simple Django module for adding structured data and OpenGraph tags to your views.

Project description

Django Structured Data PyPI

Django template tags that turn a single JSON-LD dict into rich metadata: JSON-LD script blocks, Open Graph tags, HTML meta tags, and Twitter Cards.

Install

  1. Add "structured_data" to your INSTALLED_APPS:
INSTALLED_APPS = [
    ...
    'structured_data',
]

Quick Start

Define structured data on a model

@property
def structured_data(self):
    return {
        '@type': 'BlogPosting',
        'headline': self.title,
        'description': self.summary,
        'author': {'@type': 'Person', 'name': self.author.name},
        'datePublished': self.created,
        'url': SITE_URL + self.get_absolute_url(),
        'image': {
            'url': SITE_URL + self.image.url,
            'width': 1200,
            'height': 630,
        },
    }

Render in templates

{% load jsonld opengraph meta twitter %}

{% json_ld_for post %}
{% og_for post %}
{% meta_for post %}
{% twitter_for post %}

All four tags accept either an object with a structured_data property or a plain dict.

Features

  • Template Tags — JSON-LD, Open Graph, HTML meta, and Twitter Card output with automatic property mapping and dict passthrough
  • View MixinStructuredDataMixin injects structured data into template context from any class-based view
  • Sitewide Tags — render sitewide JSON-LD and Open Graph tags from Django settings

License

This software is released under the MIT license.

Copyright (c) 2019-2026 Luke Rogers

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

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_structured_data-0.11.0.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_structured_data-0.11.0-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file django_structured_data-0.11.0.tar.gz.

File metadata

  • Download URL: django_structured_data-0.11.0.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for django_structured_data-0.11.0.tar.gz
Algorithm Hash digest
SHA256 ca660e2a06089dcbd3326d476e9039adeae9e5f2a9f83199fd9de335f5933adb
MD5 d48fd1fba8f4f7604992ad4129efefc4
BLAKE2b-256 ef5be014ed2990fd161084183ac52c6e825c53e021c4a87e580cb1e6e7303ddd

See more details on using hashes here.

File details

Details for the file django_structured_data-0.11.0-py3-none-any.whl.

File metadata

  • Download URL: django_structured_data-0.11.0-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for django_structured_data-0.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f16468fe3e34767891af46e9a5b2d84d7e7e3e42574a7e863b3a71821f15c7bb
MD5 3e98a51831b7f33c1f1ed5e98ba7a999
BLAKE2b-256 ddf8be5fdb55355d2e94eb8eb3bff6f97fcf7f7836fdb54fb7d16c71a8f646f2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page