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 Mixin: StructuredDataMixin injects structured data into template context from any class-based view
  • Sitewide Tags: Render sitewide metadata 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.13.2.tar.gz (17.0 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.13.2-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_structured_data-0.13.2.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for django_structured_data-0.13.2.tar.gz
Algorithm Hash digest
SHA256 7bfce5ade168e1e0d4f745fb96220098a25fc155126a65e0201824707a5bf202
MD5 bfa45fa9d82d96455c58a8919cd124db
BLAKE2b-256 04881c7c3d0bf151ee439e64198e43e684828a65553e6f5a3d723c388c0c8bad

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_structured_data-0.13.2.tar.gz:

Publisher: release.yml on dmptrluke/django-structured-data

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for django_structured_data-0.13.2-py3-none-any.whl
Algorithm Hash digest
SHA256 197b2056496c08a1890a0e946d9f9a3a68f88d0a912d935111f35405658f3c5e
MD5 3225b690763238546ab188d572a70c0b
BLAKE2b-256 923e68a969a0f3f3854c676750c4c60356734ec2faeb3a7b8df9840c46d71d84

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_structured_data-0.13.2-py3-none-any.whl:

Publisher: release.yml on dmptrluke/django-structured-data

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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