Fork me on GitHub

Project Notes

Minimal Django

The most bare-bones single file Django app


How basic can you make a Django app?

Install Dependencies

Using Python 3.7.3 to create and setup a virtual environment with the requirepements as specified in requirements.txt:

$ python -V
Python 3.7.3
$ python -m venv venv
$ source venv/bin/activate
$ pip install --upgrade pip
$ pip install -r requirements.txt

Hello Echo Server

Everything is in

  • minimal Django settings
  • defines an index responder
  • defines urlpatterns
  • defines wsgi application
  • if invoked as main script, defers to Django command line handler

Limitations and what is not included:

  • there is no database - this will cause problems if trying to use standard Django tests

Running with Django Development Server

Use runserver option:

$ python runserver
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
May 16, 2023 - 22:48:26
Django version 3.2.18, using settings None
Starting development server at
Quit the server with CONTROL-C.
[16/May/2023 22:48:31] "GET / HTTP/1.1" 200 12

Calling with curl:

$ curl http://localhost:8000
Hello World

Running with gunicorn

Alternatively, startup with gunicorn:

$ gunicorn hello --log-file=-
[2023-05-16 22:51:46 +0800] [35027] [INFO] Starting gunicorn 20.1.0
[2023-05-16 22:51:46 +0800] [35027] [INFO] Listening at: (35027)
[2023-05-16 22:51:46 +0800] [35027] [INFO] Using worker: sync
[2023-05-16 22:51:46 +0800] [35030] [INFO] Booting worker with pid: 35030

Calling with curl:

$ curl http://localhost:8000
Hello World

Credits and References

About LCK#232 pythondjango
Project Source on GitHub Return to the Project Catalog

This page is a web-friendly rendering of my project notes shared in the LittleCodingKata GitHub repository.

LittleCodingKata is my collection of programming exercises, research and code toys broadly spanning things that relate to programming and software development (languages, frameworks and tools).

These range from the trivial to the complex and serious. Many are inspired by existing work and I'll note credits and references where applicable. The focus is quite scattered, as I variously work on things new and important in the moment, or go back to revisit things from the past.

This is primarily a personal collection for my own edification and learning, but anyone who stumbles by is welcome to borrow, steal or reference the work here. And if you spot errors or issues I'd really appreciate some feedback - create an issue, send me an email or even send a pull-request.