Skip to content

2. A Django Project and Its First Model

The starter repo is currently just a few configuration files.

In this chapter, we'll install Django, see what its startproject command generates, and cover:

  • Projects and apps: What a project contains, what an app is for, and the settings that install our apps and connect the project to a Postgres database running in Docker.
  • Models: Defining our own models, including Animal, and using TextChoices to limit a field to a fixed set of values.
  • Migrations: Turning our Python models into database tables with makemigrations and migrate, and creating and saving an Animal from the Django shell.