Skip to content

Latest commit

 

History

History
115 lines (84 loc) · 4.07 KB

File metadata and controls

115 lines (84 loc) · 4.07 KB

HTMX + Django + PostgreSQL Railway Template

Production-ready HTMX starter with Python, Django, and PostgreSQL. One-click deploy to Railway.

Deploy on Railway

License Python 3.12 Django HTMX 2.0.7 PostgreSQL


Deploy and Host HTMX + Django + PostgreSQL Starter on Railway

Minimal Django project (no admin app in INSTALLED_APPS) focused on a Todo demo. DATABASE_URL is required and parsed with dj-database-url (SSL for non-local hosts). URLs use trailing slashes; health is GET /health/. CSRF works with HTMX via csrf_token on the form and htmx:configRequest reading data-csrf on <body>.

Dependencies for Hosting

  • Railway PostgreSQL
  • DATABASE_URL = ${{Postgres.DATABASE_URL}}

Deployment Dependencies


What's Inside

Layer Technology Role
Frontend HTMX + Tailwind (CDN) Partial updates
Templating Django templates Views + includes
Database PostgreSQL Todo model

Deploy to Railway

  1. Add PostgreSQL + web service (Dockerfile)
  2. Set DATABASE_URL
  3. Optional: DJANGO_SECRET_KEY (random string)
  4. Railway health check path: /health/ (note trailing slash)

Local Development

pip install -r requirements.txt
export DATABASE_URL="postgres://user:pass@localhost:5432/db"
python manage.py migrate
python manage.py runserver 0.0.0.0:8080

Environment Variables

Variable Required Default Description
DATABASE_URL Yes - PostgreSQL URL
DJANGO_SECRET_KEY No Dev default Set in production
PORT No 8080 Gunicorn bind port in Docker

Part of the HTMX Railway Collection

This is one of 15 HTMX starter templates covering different backend stacks, all following the same pattern and ready for Railway deployment:

Stack Status
Bun + Elysia Coming soon
.NET + Razor Coming soon
Elixir + Phoenix Coming soon
Go + Chi Live
Go + Echo Live
Go + Fiber Live
Java + Spring Boot (MySQL) Live
Java + Spring Boot (PostgreSQL) Live
Node + Express Live
Node + Hono Live
PHP + Laravel Live
Python + Django This repo
Python + FastAPI Live
Ruby + Rails 8 Live
Rust + Axum + Askama Live

License

MIT


Built by AToolZ for the HTMX community