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?

MP 98: How do you incorporate a minimal CSS framework into a Django project? Why is it worth including some styling early in a project's development?

MP 99: How you use cards to group information on a page? How does Django manage static files in a project?

MP 101: How do you create a page focusing on individual blogs? How does an ID for a specific element such as a blog get passed from the URL, to the view, and on to the template?

MP 102: How do you create a page focusing on individual posts? How can you start to develop a consistent workflow when developing a variety of Django projects?

MP 103: How do you generate realistic amounts of sample data for a project, when it doesn't have any users yet?

MP 105: How do you organize a project, to manage the increase in complexity that comes as the project grows? How can we move toward a more typical Django project structure?

MP 106: How do you implement a user authentication system with Django? How do you build login and logout functionality into a project? This post will go out Thursday, July 25.

MP 107: How do you build a user registration page, so new users can make their own accounts? How do you process forms in Django? This post will go out Thursday, August 1.

MP 109: How do you connect each blog with a specific user? How do you show that information on public-facing pages? This post will go out Thursday, August 15.

MP 110: How do we let users create new blogs? How do you build a form based on a specific model? This post will go out Thursday, August 22.