Skip to main content

django-docs-viewer

tests PyPI version Supported Python versions Supported Django versions License: MIT

A simple in-app Markdown documentation viewer for Django.

Point it at a directory of Markdown files and it serves them as browsable documentation pages with an auto-generated sidebar. No build step, no database, no models — pages are read from disk and rendered on request.

Features

  • Renders Markdown files (fenced_code, tables, toc, sane_lists, attr_list by default; configurable).
  • Auto-generated sidebar navigation grouped by folder — or hand-written via a menu.md file.
  • Automatic per-page table of contents built from each page's headings.
  • Case-insensitive, traversal-safe URL resolution.
  • Serves images referenced from your Markdown.
  • Login required by default; can be made public with one setting.
  • Self-contained, overridable templates.

How it compares

The niche is zero-build, database-free, self-navigating docs: Markdown rendered at request time, with the sidebar and per-page table of contents built from the folder tree and headings. django-markdown-view also renders at request time but builds no navigation; Django Spellbook builds navigation but via a generation step and as part of a larger Markdown-components framework.

Installation

pip install django-docs-viewer

Usage

Add the app to INSTALLED_APPS and point DOCS_VIEWER_ROOT at your docs directory:

# settings.py
INSTALLED_APPS = [
    # ...
    "docs_viewer",
]

DOCS_VIEWER_ROOT = BASE_DIR / "docs"

Include the URLs:

# urls.py
from django.urls import include, path

urlpatterns = [
    # ...
    path("docs/", include("docs_viewer.urls")),
]

By default the docs require an authenticated user and redirect anonymous visitors to LOGIN_URL, so make sure your project has a login view — or set DOCS_VIEWER_LOGIN_REQUIRED = False to make the docs public.

Your docs directory can be flat:

docs/
├── README.md                     # landing page + site title
├── 01-getting-started.md
└── 02-configuration.md

or nested, with folders becoming sidebar groups:

docs/
├── README.md                     # landing page + site title
└── manual/
    ├── 01-getting-started.md
    ├── 02-configuration.md
    └── images/
        └── status-legend.png

Folders nest to any depth, and each level becomes a sidebar group, so a subfolder per language keeps translated pages neatly separated instead of listing every language in one flat group:

docs/
├── README.md                     # landing page + site title
└── manual/
    ├── deutsch/
    │   ├── 01-erste-schritte.md
    │   └── 02-konfiguration.md
    ├── english/
    │   ├── 01-getting-started.md
    │   └── 02-configuration.md
    └── francais/
        ├── 01-prise-en-main.md
        └── 02-configuration.md

Group labels come from the folder name, humanized (dashes and underscores become spaces, and it is title-cased), so name folders in lowercase — deutsch renders as Deutsch in the sidebar.

Pages sort by filename within their folder (the index/README first). Prefix filenames with a zero-padded number (01-, 02-) to control the order; the prefix is stripped from the sidebar label, so 01-getting-started.md shows as Getting started. Zero-pad once you pass nine pages, otherwise 10-… sorts ahead of 2-….

Settings

Setting Default Description
DOCS_VIEWER_ROOT (required) Path to the directory containing your Markdown files.
DOCS_VIEWER_BASE_TEMPLATE "docs_viewer/base.html" Template the docs page extends. Point at your own layout.
DOCS_VIEWER_LOGIN_REQUIRED True Redirect anonymous users to LOGIN_URL. Set False to make docs public.
DOCS_VIEWER_TITLE "Documentation" Fallback page title when no index heading is available.
DOCS_VIEWER_BACK_URL "/" Target of the header's "Back" link: a path, full URL or URL name (resolved like LOGIN_URL). Set None to hide the link.
DOCS_VIEWER_TOC_DEPTH "2-3" Heading levels included in the per-page table of contents.
DOCS_VIEWER_SKIP_DIRS ["_*"] Glob patterns; directories matching any are hidden (excluded from navigation and not served). A custom value replaces the default, so include "_*" if you still want underscore-prefixed directories hidden.
DOCS_VIEWER_MARKDOWN_EXTENSIONS ["fenced_code", "tables", "toc", "sane_lists", "attr_list"] Python-Markdown extensions used to render pages: names or Extension instances (e.g. CodeHiliteExtension(linenums=True)). A custom value replaces the default; keep "toc" for the per-page table of contents.

The page title is taken from the first level-1 heading of the index (index.md or README.md) at the docs root, falling back to DOCS_VIEWER_TITLE.

Markdown extensions

DOCS_VIEWER_MARKDOWN_EXTENSIONS replaces the default list. To add extensions while keeping the defaults, extend DEFAULT_MARKDOWN_EXTENSIONS:

from docs_viewer.conf import DEFAULT_MARKDOWN_EXTENSIONS
from pymdownx.tasklist import TaskListExtension

DOCS_VIEWER_MARKDOWN_EXTENSIONS = [
    *DEFAULT_MARKDOWN_EXTENSIONS,
    "pymdownx.tasklist",  # by name, with default options
    # TaskListExtension(custom_checkbox=True),  # or as an instance, with options
]

To swap or drop a default, list the extensions explicitly instead, e.g. replace fenced_code with pymdownx.superfences:

DOCS_VIEWER_MARKDOWN_EXTENSIONS = ["pymdownx.superfences", "tables", "toc", "sane_lists", "attr_list"]

Keep toc in the list for the per-page table of contents and heading anchors.

Customizing the template

The docs page (docs_viewer/detail.html) extends whatever template DOCS_VIEWER_BASE_TEMPLATE names, resolved dynamically at render time. By default it extends the minimal docs_viewer/base.html bundled with the app, so it works with no configuration.

To make docs pages inherit your site's chrome, point the setting at your own base template:

DOCS_VIEWER_BASE_TEMPLATE = "myproject/base.html"

Your base template only needs a content block (and, optionally, a title block):

{% block title %}{% endblock %}
...
{% block content %}{% endblock %}

To change the docs page itself rather than the surrounding layout, override docs_viewer/detail.html in your own template directory. To replace only the header's back link, extend it and override the docs_back_link block:

{% extends "docs_viewer/detail.html" %}
{% block docs_back_link %}<a class="docs-back" href="/app/">Back to the app</a>{% endblock %}

Custom navigation

By default the sidebar is generated from your folder tree. To control it by hand instead, add a menu.md file at the root of your docs directory. When present, its rendered Markdown replaces the auto-generated sidebar (and menu.md itself is never served as a page).

Write it as a normal Markdown list of links:

- [Introduction](/docs/)
- [Getting started](/docs/manual/01-getting-started)
- [Configuration](/docs/manual/02-configuration)

The links are rendered as-is, so point them at the paths where you mounted the viewer — the /docs/ prefix above matches path("docs/", include(...)).

Translations

The interface strings ship translated into English, German and French. The active language follows Django's usual i18n machinery, so enable django.middleware.locale.LocaleMiddleware (and keep USE_I18N = True) if you want the docs to follow the request's language.

Development

poetry install
poetry run python manage.py test tests

Run the full support matrix with tox:

poetry run tox

See CONTRIBUTING.md for coverage, translations, and the pull-request checklist.

License

MIT

Metadata

Release files for django-docs-viewer 0.3.0

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-docs-viewer 0.3.0
File Size Uploaded Provenance Actions
django_docs_viewer-0.3.0.tar.gz 13.6 kB With provenance Details for django_docs_viewer-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-docs-viewer 0.3.0
File Interpreter ABI Platform Actions
django_docs_viewer-0.3.0-py3-none-any.whl Python 3 none any Details for django_docs_viewer-0.3.0-py3-none-any.whl

Total release size: 29.6 kB

Release files / django_docs_viewer-0.3.0.tar.gz

Download URL django_docs_viewer-0.3.0.tar.gz
Size 13.6 kB
Tags Source
SHA-256 checksum
How to use checksums
b6d7e7e4467fe7be9c65ea5870731a40b704f00d1c393308843ac56d85880e0a
BLAKE2b-256 checksum
How to use checksums
c9e28a6f5e75bef407dcfe6b8dd0a6df3dd2db81309a58099c87bd843fbe863c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

Release files / django_docs_viewer-0.3.0-py3-none-any.whl

Download URL django_docs_viewer-0.3.0-py3-none-any.whl
Size 16.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4d1655d4138de1053f242dd2bdbd6d7c49e31147fd10a7cbf204f1ed24f013e1
BLAKE2b-256 checksum
How to use checksums
e610b3a599b349ac3cc64940c5b6dcb87c206b3f347156446699e4994cf57b3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

Security for django-docs-viewer 0.3.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for django_docs_viewer-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

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