A modern, production-ready full-stack template combining Django REST Framework with SvelteKit, featuring authentication, CRUD operations, dark mode, and a complete todo application demo.
š Live Demo | š Documentation
š Read the Architecture Guide for a detailed technical overview of the codebase
Clone and install dependencies:
npm run setup
This will:
django_svelte_env/
)On Windows, if Python command fails, try:
npm run install
npm run setup:python-win
Set up environment variables:
cp .env.example .env
# Edit .env with your settings
Run database migrations:
npm run migrate
On Windows:
npm run migrate:win
Create a superuser:
npm run createsuperuser
On Windows:
npm run createsuperuser:win
Start development servers:
npm run dev
The application will be available at:
Development:
npm run dev
- Start both frontend and backend development serversnpm run dev:backend
- Start only Django development servernpm run dev:frontend
- Start only SvelteKit development servernpm run setup
- Install all dependenciesnpm run setup:dev
- Install all dependencies including development toolsDatabase:
npm run migrate
- Run Django migrationsnpm run createsuperuser
- Create Django superuserBuilding & Deployment:
npm run build
- Build frontend for productionnpm run collectstatic
- Collect static filesCode Quality:
npm run lint
- Lint both frontend and backend codenpm run lint:frontend
- Lint frontend code with ESLintnpm run lint:backend
- Lint backend code with flake8npm run format
- Format both frontend and backend codenpm run format:frontend
- Format frontend code with Prettiernpm run format:backend
- Format backend code with Black and isortTesting:
npm run test
- Run backend testsnpm run test:backend
- Run Django testsWindows-specific (if python3 command fails):
npm run setup:python-win
- Install Python dependencies on Windowsnpm run migrate:win
- Run Django migrations on Windowsnpm run createsuperuser:win
- Create Django superuser on Windowsnpm run collectstatic:win
- Collect static files on WindowsSQLite (Default):
docker-compose up
PostgreSQL:
docker-compose -f docker-compose.postgres.yml up
Production:
docker-compose -f docker-compose.prod.yml up
django-svelte-template/
āāā backend/ # Django application
ā āāā django_svelte_template/
ā ā āāā settings.py # Django settings
ā ā āāā urls.py # URL configuration
ā ā āāā api/ # API application
ā ā āāā models.py # Data models
ā ā āāā views.py # API views
ā ā āāā serializers.py
ā ā āāā urls.py
ā āāā templates/ # Django templates
ā āāā manage.py
āāā frontend/ # SvelteKit application
ā āāā src/
ā ā āāā routes/ # SvelteKit routes
ā ā āāā lib/
ā ā ā āāā components/ # Svelte components
ā ā ā āāā api.ts # API client
ā ā ā āāā stores.ts # Svelte stores
ā ā āāā app.css
ā āāā package.json
ā āāā vite.config.js
āāā django_svelte_env/ # Python virtual environment
āāā requirements.txt # Python dependencies
āāā package.json # Node.js dependencies
āāā docker-compose.yml # Docker configuration
āāā README.md # Setup and usage guide
āāā ARCHITECTURE.md # Technical documentation
POST /api/login/
- User loginPOST /api/logout/
- User logoutGET /api/user/
- Get current user infoGET /api/csrf/
- Get CSRF tokenGET /api/todos/
- List todosPOST /api/todos/
- Create todoGET /api/todos/{id}/
- Get todo detailPATCH /api/todos/{id}/
- Update todoDELETE /api/todos/{id}/
- Delete todoBuild frontend:
npm run build
Collect static files:
npm run collectstatic
Set environment variables:
DEBUG=False
SECRET_KEY
ALLOWED_HOSTS
Use a production WSGI server like Gunicorn:
pip install gunicorn
gunicorn django_svelte_template.wsgi:application
Python command not found:
python3
instead of python
python
or ensure Python is in your PATH:win
suffix)npm vulnerabilities or dependency conflicts:
npm run clean-install
# OR manually:
cd frontend
rm -rf node_modules package-lock.json
npm install
CORS issues:
Database issues:
# Reset database
rm backend/db.sqlite3
npm run migrate
npm run createsuperuser
Static files not loading:
npm run build
npm run collectstatic
Manual virtual environment activation:
# Activate virtual environment manually (if needed)
source django_svelte_env/bin/activate # macOS/Linux
# OR
django_svelte_env\Scripts\activate # Windows
# Your prompt should show: (django_svelte_env) $
MIT License - see LICENSE file for details.