- Python 84.5%
- HTML 14.5%
- CSS 0.7%
- Dockerfile 0.3%
|
|
||
|---|---|---|
| .woodpecker | ||
| attendee | ||
| badges | ||
| cart | ||
| config | ||
| events | ||
| marketplace | ||
| payments | ||
| staff | ||
| static_src | ||
| templates | ||
| tenants | ||
| tests | ||
| .env.example | ||
| .gitignore | ||
| .python-version | ||
| conftest.py | ||
| docker-compose.yml | ||
| Dockerfile | ||
| labb.yaml | ||
| manage.py | ||
| package-lock.json | ||
| package.json | ||
| pyproject.toml | ||
| README.md | ||
| uv.lock | ||
mndr_reg
A multi-tenant Django 6 application using django-tenants with a labb component UI layer (Tailwind CSS + daisyUI 5).
Tech Stack
- Python 3.12+
- Django 6.0
- django-tenants — PostgreSQL schema-based multi-tenancy
- labb (labbui + labbicons) — Django Cotton component library
- Tailwind CSS 4.2 + daisyUI 5 — styling
- uv — Python package manager
Prerequisites
- Python 3.12.1+
- PostgreSQL
- Node.js (for Tailwind CSS builds)
- uv
Getting Started
1. Clone the repo
git clone ssh://git@git.mndr.me:222/meander/mndr-reg.git
cd mndr_reg
2. Install Python dependencies
uv sync
3. Install Node dependencies
npm install
4. Configure environment
cp .env.example .env
Edit .env with your settings:
DEBUG=True
SECRET_KEY=your-secret-key
DATABASE_URL=postgres://postgres:postgres@localhost:5432/mndr_reg
5. Create the database
createdb mndr_reg
6. Run migrations
uv run python manage.py migrate_schemas --shared
7. Create the public tenant
uv run python manage.py create_public_tenant
8. Run the development servers
In one terminal, start the CSS watcher:
uv run labb dev
In another terminal, start Django:
uv run python manage.py runserver
Project Structure
mndr_reg/
├── config/ # Django project settings, URLs, WSGI/ASGI
├── tenants/ # Multi-tenancy app (Tenant & Domain models)
├── templates/ # Global templates
├── static_src/ # Tailwind CSS input
├── labb.yaml # labb CSS build configuration
├── pyproject.toml # Python dependencies (uv)
└── package.json # Node dependencies (Tailwind, daisyUI)
Multi-Tenancy
This project uses PostgreSQL schema-based tenancy via django-tenants. Each tenant gets its own schema with isolated data. The public schema holds shared tables (tenants, domains).
- Tenant model:
tenants.Tenant - Domain model:
tenants.Domain
Tenants are routed by domain — the TenantMainMiddleware resolves the current tenant from the request host.
Managing Tenants
Create a superuser in the public schema to manage tenants via the admin:
uv run python manage.py tenant_command createsuperuser --schema=public
Then log in at http://localhost:8000/admin/ to create and manage tenants and domains.
Order of operations: Create a Tenant first, then assign Domain(s) to it. The admin form lets you do both in one step via the inline.
Creating Users in a Specific Tenant
Each tenant has its own user table. To create a superuser within a tenant's schema:
uv run python manage.py tenant_command createsuperuser --schema=acme
Local Domain Routing
For local development, add tenant domains to /etc/hosts:
127.0.0.1 acme.localhost
Then assign acme.localhost as the domain for that tenant in the admin. Access it at http://acme.localhost:8000.
labb UI
Components use Django Cotton syntax (<c-lb.component>). Run labb dev during development to watch templates and rebuild CSS automatically.
Useful CLI commands:
labb components inspect <component> # View component specs
labb components ex <component> # View usage examples
labb icons search "term" # Search available icons