A lightweight forum system built with Django.
中文文档 | Live Demo: lforum.dpdns.org
- Markdown editor with LaTeX math support
- Post creation, comments, and deletion
- Personal profile page with avatar upload (falls back to a letter avatar)
- Post collections
- AI bot (mention
@botin a post) - Web Push browser notifications
- Light/Dark theme toggle
- RESTful API (Django REST Framework)
- Docker deployment support
- Backend: Django 5.2+, Django REST Framework
- Frontend: Bootstrap 5.3, Bootstrap Icons, github-markdown-css, MathJax
- Editor: django5-mdeditor
- Database: SQLite (default)
- Other: django-webpush, bleach, OpenAI API
- Python 3.10+
Double-click dev.bat, or from PowerShell:
.\dev.ps1It takes a fresh clone all the way to a running server: creates the virtualenv if
missing (picking a 3.10+ interpreter on purpose — the python on your PATH is
often an older one without Django), installs dependencies when they changed,
generates and applies migrations, then serves on http://127.0.0.1:8000.
.\dev.ps1 -Superuser # also create an admin account (random password, printed)
.\dev.ps1 -Port 9000 -Address 0.0.0.0 # different port, reachable from the LAN
.\dev.ps1 -Test # run the test suite only
.\dev.ps1 -NoSetup # don't touch the environment, just startWhy this exists: the repo keeps
migrations/in.gitignore, so a fresh clone has no migration files at all and nothing can be created until you generate them; and withoutDEBUG=1every asset under/static/(including the Markdown editor) 404s. Both are easy to trip over on a first run.
git clone https://github.com/aba2222/lean_forum.git
cd lean_forum
python -m venv venv
# Linux/macOS:
source venv/bin/activate
# Windows:
venv\Scripts\activate
pip install -r requirements.txt
# note the explicit app names, see below
python manage.py makemigrations forum md_editor
python manage.py migrate
export DEBUG=1
python manage.py runserver
makemigrationsneeds the explicitforum md_editorapp labels. Without them, Django skips apps that don't have amigrationspackage yet — which is exactly the state of a fresh clone, soforumgets no tables and every page fails withno such table: forum_post.
Visit http://127.0.0.1:8000
docker build -t lean-forum .
docker run -p 8000:8000 lean-forumpython manage.py migrate
gunicorn lean_forum.wsgi:application --bind 0.0.0.0:8000Read-only RESTful API. Anonymous read access; write operations require authentication.
GET /api/posts/?limit=20&offset=0
GET /api/posts/{id}/
| Variable | Description | Default |
|---|---|---|
SECRET_KEY |
Django secret key | Built-in dev key |
DEBUG |
Debug mode; only 1/true/yes/on enables it |
0 |
SERVE_MEDIA |
Serve /media/ uploads (avatars, post images) from Django. Set to 0 when a front-end server (nginx/CDN) already handles /media/ |
1 |
SERVE_STATIC |
Serve /static/ from Django (requires collectstatic). Set to 0 when a front-end server handles /static/ |
1 |
Local development: set
DEBUG=1. With debug on,runserverserves app static files (including the Markdown editor) directly, socollectstaticis not needed.
AGPL-3.0