Skip to main content

Django Mermaid

PyPI Python Django License Tests

Mermaid is a JavaScript-based diagramming and charting tool that renders Markdown-inspired text definitions to create and modify diagrams dynamically. And Django Mermaid aims to use mermaid diagrams in Django templates.

Installation

python -m pip install django-mermaid

Configuration

Add the django_mermaid.apps.MermaidConfig to your INSTALLED_APPS in your Django project's settings.py file.

INSTALLED_APPS = [
    ...,  # other apps
    'django_mermaid.apps.MermaidConfig',
]

Usage

After you configure the INSTALLED_APPS, you will be able to load the mermaid in your template and use the template tags for rendering mermaid diagrams.

{% load mermaid %}

{# for small diagrams #}
{% mermaid "graph LR; A-->B;" %}

{# for larger diagrams #}
{% startmermaid %}
    graph LR
        A-->B
{% endmermaid %}

Mermaid version

By default, Django Mermaid uses the 9.4.3 version of mermaid. However, if you want to use a specific version of mermaid, you can set the MERMAID_VERSION variable in your Django project's settings.py file.

MERMAID_VERSION = '10.0.3-alpha.1'

Make sure the version you specify is available on the mermaid CDN, and has the mermaid.min.js file.

Mermaid theme

To set a default theme for the whole project, set the MERMAID_THEME variable in your Django project's settings.py file. However, Django Mermaid uses the default theme of mermaid by default. Also, check out the mermaid docs for the available themes.

MERMAID_THEME = 'neutral'

Also, you can provide the theme right in the template tag which will dynamically override the value of the MERMAID_THEME variable.

{% mermaid "graph LR; A-->B;" "dark" %}
{% startmermaid "dark" %}graph LR; A--B;{% endmermaid %}

Mermaid use CDN

By default, Django Mermaid uses the local copy of mermaid from staticfiles. However, if you want to use the CDN version directly, you can set the MERMAID_USE_CDN variable in your Django project's settings.py file.

MERMAID_USE_CDN = True

Mermaid theme variables

You can define your custom theme by overriding the MERMAID_THEME_VARIABLES variable. You will need to use the base theme as it is the only modifiable theme. Check out the mermaid docs for the complete and up-to-date list of available theme variables.

MERMAID_THEME_VARIABLES = {
    'primaryColor': '#BB2528',
    'primaryTextColor': '#FFF',
}

Contribute

Any contribution is welcome. If you have any ideas or suggestions, feel free to open an issue or a pull request. And don't forget to add tests for your changes.

License

Copyright (C) 2023 Artyom Vancyan. MIT

Metadata

Release files for django-mermaid 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-mermaid 0.1.1
File Size Uploaded Provenance Actions
django_mermaid-0.1.1.tar.gz 7.9 kB Without provenance Details for django_mermaid-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-mermaid 0.1.1
File Interpreter ABI Platform Actions
django_mermaid-0.1.1-py3-none-any.whl Python 3 none any Details for django_mermaid-0.1.1-py3-none-any.whl

Total release size: 14.2 kB

Release files / django_mermaid-0.1.1.tar.gz

Download URL django_mermaid-0.1.1.tar.gz
Size 7.9 kB
Tags Source
SHA-256 checksum
How to use checksums
1430802794c1de3ed8282aa7217e67e0c6e61147b792b2d28d6332349868eb37
BLAKE2b-256 checksum
How to use checksums
f872cb8dc3bdd8e44976f123551ff957e86dc6ab5c179110f03752635d778ff9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / django_mermaid-0.1.1-py3-none-any.whl

Download URL django_mermaid-0.1.1-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
045d9ff26aa82bde93dd1bc759af887524a18d58937516c176c3e78b367fcc84
BLAKE2b-256 checksum
How to use checksums
89c9d25fb8bb2f554bf1e6cfea08e77fddaaeebaa05f47fc67e4d83a89d7d6fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Security for django-mermaid 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page