Django from first principles

Most Django tutorials and resources start by running two commands: django-admin startproject, followed by manage.py startapp. This is a reasonable way for experienced Django developers to start new projects, because it sets up an overall structure that makes sense for most web apps. This approach is not necessarily best, however, for people new to web development. If you start with those two commands, you have about twelve files to make sense of before you even write one line of your own code.

Many people don't realize you can start a Django project with a single file. This series walks through the process of building a simple but non-trivial project by starting with a single file. The project only expands to additional files when it makes sense to move code out of the main file. By the end of the series, we'll have a project with a structure similar to what's generated by startproject and startapp.


This series is ongoing. All posts are available to everyone as soon as they come out.

MP 90: What's the structure of a typical Django project before you start writing your own code? How much can that structure be simplified? What is a "simple but nontrivial" project? This post has a lengthy footnote about other work that has inspired this series.

MP 91: How does a web app work? How can you serve a simple home page from a single file with Django?

MP 92: How can you use templates to manage the complexity of actual HTML pages in a project? How can we move settings out of the project's main file?

MP 94: How do you model the data you want to work with in your project? How do you use Django to efficiently manage the actual data that's stored in your project?

MP 95: How do you establish relationships between different pieces of information in a project? How do you retrieve exactly what you need from the database?

MP 96: How do you build a page that includes data from the database? How do you link between pages in a project? This post will go out Thursday, May 16.