Skip to main content

django-site-documentation

A reusable Django application that provides a structured documentation system served on a dedicated URL path (or optionally a subdomain). Content is rendered from .md files located within each Django app's directory.

Security Requirements

When deploying this application in production, the following settings must be configured:

  • SESSION_COOKIE_SECURE = True — ensures session cookie is only sent over HTTPS.
  • CSRF_COOKIE_SECURE = True — ensures CSRF cookie is only sent over HTTPS.
  • SESSION_COOKIE_HTTPONLY = True — prevents JavaScript access to the session cookie.
  • SECURE_HSTS_SECONDS = 31536000 — enables HTTP Strict Transport Security (start with a lower value during rollout).
  • SECURE_SSL_REDIRECT = True — redirects all HTTP traffic to HTTPS.
  • SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') — required when behind a reverse proxy.

Additionally, add django_site_documentation.middleware.ContentSecurityPolicyMiddleware to your MIDDLEWARE list (after SecurityMiddleware) to enable Content Security Policy headers:

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    ...
    'django_site_documentation.middleware.ContentSecurityPolicyMiddleware',
]

Concepts

  • Library: The entire documentation site
  • Shelf: A Django app that contains documentation
  • Chapter: A folder inside django-doc/
  • Page: A .md file inside a chapter folder

Quick Start

  1. Install the package:

    pip install django-site-documentation
    
  2. Add to INSTALLED_APPS:

    INSTALLED_APPS = [
        ...
        'django_site_documentation',
    ]
    
  3. Configure the documentation URL in settings.py:

    DOCUMENTATION_DOMAIN = 'localhost:8000/doc'
    
  4. Add the middleware after SessionMiddleware and AuthenticationMiddleware:

    MIDDLEWARE = [
        'django.contrib.sessions.middleware.SessionMiddleware',
        'django.contrib.auth.middleware.AuthenticationMiddleware',
        ...
        'django_site_documentation.middleware.DocumentationDomainMiddleware',
    ]
    
  5. Login directly on the documentation URL — the app includes its own login/logout views at localhost:8000/doc/login/. Just make sure your user is a superuser to access edit features.

  6. Add the documentation URL to ALLOWED_HOSTS and CSRF_TRUSTED_ORIGINS (no subdomains needed):

    ALLOWED_HOSTS = [
        'example.com',
        'localhost',          # local development
    ]
    CSRF_TRUSTED_ORIGINS = [
        'https://example.com',
        'http://localhost:8000',  # dev
    ]
    
  7. Create documentation in any installed app:

    yourapp/
    └── django-doc/
        ├── getting-started/
        │   ├── index.md
        │   └── installation.md
        └── guides/
            └── advanced-usage.md
    

Frontmatter

Each .md file can include YAML frontmatter for metadata:

---
title: My Page Title
order: 1
---

Chapters can use an index.md file to set chapter-level metadata.

Metadata

Release files for django-site-documentation 1.0.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-site-documentation 1.0.1
File Size Uploaded
django_site_documentation-1.0.1.tar.gz 138.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-site-documentation 1.0.1
File Interpreter ABI Platform
django_site_documentation-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 285.2 kB

Release files / django_site_documentation-1.0.1.tar.gz

Download URL django_site_documentation-1.0.1.tar.gz
Size 138.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f395344def38c1c971902c4dec6ee9a26bbc6d7fccaaa1c150ebe4c8613605e7
BLAKE2b-256 checksum
How to use checksums
17e9e821fd6dc1228cacf7c86854de108c338608a2ad89c00648b179ae965582
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / django_site_documentation-1.0.1-py3-none-any.whl

Download URL django_site_documentation-1.0.1-py3-none-any.whl
Size 146.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1c26ce21a9b24a4c1a979f8c63e1e090358b42ba36582b6fc1172d748d6c4f7b
BLAKE2b-256 checksum
How to use checksums
05a2e574536a69387fd96c84b2af2ecc356a0e5fff7e2235c514776af597f95f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

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