A Django project template for single-file micro Django applications with Django REST Framework.
Two template variants are available:
| Template | Directory | Description |
|---|---|---|
| REST | project_name/ |
Django + DRF, WSGI |
| REST + WebSockets | project_name_ws/ |
Django + DRF + Channels, ASGI with WebSocket support |
pip install django djangorestframework
django-admin startproject myproject --template=./project_name -e py
python myproject/myproject.py runserverpip install django djangorestframework channels daphne channels-redis
django-admin startproject myproject --template=./project_name_ws -e py
daphne myproject.myproject:application -b 0.0.0.0 -p 8000The WebSocket template uses REDIS_URL to switch channel layers:
REDIS_URL |
Channel Layer |
|---|---|
Set (e.g. redis://localhost:6379/0) |
RedisChannelLayer |
| Unset | InMemoryChannelLayer |
A single Python file (myproject.py) that includes:
- Django settings configured inline via
settings.configure() - Django REST Framework with JSON rendering
- URL routing
- WSGI or ASGI application
manage.py-style CLI (python myproject.py runserver,python myproject.py migrate, etc.)
The WebSocket variant also generates a myproject_consumers.py with a sample echo consumer.
Django's startproject replaces these automatically:
| Variable | Description |
|---|---|
{{ project_name }} |
Project name (directory + filename) |
{{ secret_key }} |
Randomly generated SECRET_KEY |