Skip to main content

A reusable Django app providing a structured documentation system (Library > Shelf > Book > Chapter > Page) served on a dedicated URL path (or optionally a subdomain), rendering content from .md files within each Django app.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_site_documentation-1.0.1.tar.gz (138.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_site_documentation-1.0.1-py3-none-any.whl (146.8 kB view details)

Uploaded Python 3

File details

Details for the file django_site_documentation-1.0.1.tar.gz.

File metadata

File hashes

Hashes for django_site_documentation-1.0.1.tar.gz
Algorithm Hash digest
SHA256 f395344def38c1c971902c4dec6ee9a26bbc6d7fccaaa1c150ebe4c8613605e7
MD5 bd0b273964221341e68a1f8e58840092
BLAKE2b-256 17e9e821fd6dc1228cacf7c86854de108c338608a2ad89c00648b179ae965582

See more details on using hashes here.

File details

Details for the file django_site_documentation-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_site_documentation-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1c26ce21a9b24a4c1a979f8c63e1e090358b42ba36582b6fc1172d748d6c4f7b
MD5 94ecb3ddc55ea9d2f161d692d5a62269
BLAKE2b-256 05a2e574536a69387fd96c84b2af2ecc356a0e5fff7e2235c514776af597f95f

See more details on using hashes here.

Supported by

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