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
.mdfile inside a chapter folder
Quick Start
-
Install the package:
pip install django-site-documentation
-
Add to
INSTALLED_APPS:INSTALLED_APPS = [ ... 'django_site_documentation', ]
-
Configure the documentation URL in
settings.py:DOCUMENTATION_DOMAIN = 'localhost:8000/doc'
-
Add the middleware after
SessionMiddlewareandAuthenticationMiddleware:MIDDLEWARE = [ 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', ... 'django_site_documentation.middleware.DocumentationDomainMiddleware', ]
-
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. -
Add the documentation URL to
ALLOWED_HOSTSandCSRF_TRUSTED_ORIGINS(no subdomains needed):ALLOWED_HOSTS = [ 'example.com', 'localhost', # local development ] CSRF_TRUSTED_ORIGINS = [ 'https://example.com', 'http://localhost:8000', # dev ]
-
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)
| File | Size | Uploaded | |
|---|---|---|---|
| django_site_documentation-1.0.1.tar.gz | 138.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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
|