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 tag for rendering mermaid diagrams.

{% load mermaid %}
{% mermaid "graph LR; A-->B;" %}

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" %}

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.0.7

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.0.7
File Size Uploaded
django-mermaid-0.0.7.tar.gz 6.4 kB Details

Built distribution (wheel)

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

Total release size: 12.0 kB

Release files / django-mermaid-0.0.7.tar.gz

Download URL django-mermaid-0.0.7.tar.gz
Size 6.4 kB
Tags Source
SHA-256 checksum
How to use checksums
8642b109398adb55a5d33485e16254c683ef6764308e2c6911fd71664c124648
BLAKE2b-256 checksum
How to use checksums
82fe0c0a07741b814f27e2aff27de5b7ddd53cf641003f74bbaefc256bb6c70c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

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

Download URL django_mermaid-0.0.7-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e0b6505f809cd9b140f433fc5d5eeff82312cc0f5048d0bb9efe7422042803b9
BLAKE2b-256 checksum
How to use checksums
1467d052157ad0fd65cb2d703399bbb911ba0144870cf4d4c8ec2e19fbb47e72
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release history Release notifications | RSS feed

0.1.1

2 release files

0.1.0

2 release files

0.0.9

2 release files

0.0.8

2 release files

This release

0.0.7 This release

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

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