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.4.tar.gz (16.8 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.4-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for django_structured_data-0.13.4.tar.gz
Algorithm Hash digest
SHA256 459eb398924cc8d1f84f782a43087406b2ebba2d27e425469736c5dcbda2e7c1
MD5 e6e57ff92fcc4a08b4eac0546ba5e3a2
BLAKE2b-256 c7af993dc9c5611eb739549352ab349aa9ea418e5b294969e1d756dbd55e5430

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_structured_data-0.13.4.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.4-py3-none-any.whl.

File metadata

File hashes

Hashes for django_structured_data-0.13.4-py3-none-any.whl
Algorithm Hash digest
SHA256 8bd024ec186bd19242be50f42bc0404ebfd05bf7d540d3be1fef9599a79118e7
MD5 23ec365d66f8400496cb2fc213d12079
BLAKE2b-256 558a1dc4c0340711b785153efb211bb425cb4f2006af6da1656f15459b8615bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_structured_data-0.13.4-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