Skip to main content
2025 Python Packaging Survey is now live!  Take the survey now

Structured data with Django

Project description

Structured data with Django

Latest Version codecov Build Status License: MIT

Installation

pip install djld

Configuration

Add djld to your INSTALLED_APPS in settings.py, you can specify the folder containing your structured data overriding the LD_JSON_PATH variable

Usage

To render structured data in your templates you need the structured_data template tag

{% load djld %}

{% structured_data 'mydata.json' %}

You can use Django template sintax in your json files, and pass a context to the template tag

render(request, 'myapp/index.html', {
    'user_data' : {
        'url' : 'https://lotrek.it',
        'name' : 'Human Before Digital'
    }
})
{% load djld %}

{% structured_data 'mydata.json' user_data %}

You can also render a structured data from a dictionary, without using templates

render(request, 'myapp/index.html', {
    'user_data' : {
        'url' : 'https://lotrek.it',
        'name' : 'Human Before Digital'
    }
})
{% load djld %}

{% structured_data user_data %}

Run tests

$ pip install -r requirements-dev.txt
$ make test

Supported by

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