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.0.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.0-py3-none-any.whl (146.8 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for django_site_documentation-1.0.0.tar.gz
Algorithm Hash digest
SHA256 091687308dff53b4802c530c86f31898e4dec8eade5bfb302f090e56639d098b
MD5 8519c54117fa936f119250485ea1ca96
BLAKE2b-256 cdfa88b8d66ab708ccea943830d70acdf3a262d0dabbf3338436c98ad1ce03fe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_site_documentation-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 544db34933bf2ffd5ad439db09b7da6672ee7fef6c111c215afb309c937b757c
MD5 8b3bd66ebc17e45a738bc331f7ea4a6b
BLAKE2b-256 472416f85677c40af1b4a39b630e07bc23603811b5282961d2b922407e673f69

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