Skip to content

aFraley/tiny-django

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

tiny-django

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

Quick Start

REST only

pip install django djangorestframework
django-admin startproject myproject --template=./project_name -e py
python myproject/myproject.py runserver

REST + WebSockets

pip 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 8000

The WebSocket template uses REDIS_URL to switch channel layers:

REDIS_URL Channel Layer
Set (e.g. redis://localhost:6379/0) RedisChannelLayer
Unset InMemoryChannelLayer

What You Get

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.

Template Variables

Django's startproject replaces these automatically:

Variable Description
{{ project_name }} Project name (directory + filename)
{{ secret_key }} Randomly generated SECRET_KEY

About

A Django Project Template for building a Micro Django application

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages