This repository contains the Django project you build in the official
Django tutorial: the mysite
project with the polls
app.
Each commit corresponds to a step in the tutorial.
If you get stuck while following the tutorial, you can check what your code should look like - right at the step you are currently at.
For further motivation, visit https://consideratecode.com/2017/12/15/django-tutorial-step-by-step
There is a tagged commit for each complete code change. The commit message indicated which step of the tutorial the commit refers to.
In most cases, each commit corresponds to the state of your project after a single section or sub-section in the tutorial.
Sometimes, a section contains multiple code changes that you should try one after the other, e.g. the section "Customize the admin change list" in Part 7 corresponds to five commits.
Here is a list of all steps in the tutorial, linked to the corresponding tag. The name of each tag is shown in brackets.
Part 1:
- Part 1: Creating a project [2.0/1.1]
- Part 1: Creating the Polls app [2.0/1.2]
- Part 1: Writing your first view [2.0/1.3]
Part 2:
- Part 2: Database setup [2.0/2.1]
- Step 2: Creating models [2.0/2.2]
- Part 2: Activating models [2.0/2.3]
- Part 2: Playing with the API [2.0/2.4]
- Part 2: Introducing the Django Admin [2.0/2.5]
Part 3:
- Part 3: Writing more views [2.0/3.1]
- Part 3: Write views that actually do something [2.0/3.2]
- Part 3: Write views that actually do something - with templates [2.0/3.2.1]
- Part 3: Write views that actually do something - A shortcut: render() [2.0/3.2.2]
- Part 3: Raising a 404 error [2.0/3.3.1]
- Part 3: Raising a 404 error - A shortcut: get_object_or_404() [2.0/3.3.2]
- Part 3: Use the template system [2.0/3.4]
- Part 3: Removing hardcoded URLs in templates [2.0/3.5]
- Part 3: Namespacing URL names [2.0/3.6]
Part 4
- Part 4: Write a simple form [2.0/4.1.1]
- Part 4: Write a simple form - results view [2.0/4.1.2]
- Part 4: Use generic views: Less code is better [2.0/4.2]
Part 5:
- Part 5: Writing our first test - Create a test to expose the bug [2.0/5.1.1]
- Part 5: Writing our first test - Fixing the bug [2.0/5.1.2]
- Part 5: Writing our first test - More comprehensive tests [2.0/5.1.3]
- Part 5: Test a view - Improving our view [2.0/5.2.1]
- Part 5: Test a view - Testing our new view [2.0/5.2.2]
- Part 5: Test a view - Testing the DetailView [2.0/5.2.3]
Part 6:
- Part 6: Customize your app’s look and feel [2.0/6.1]
- Part 6: Adding a background-image [2.0/6.2]
Part 7:
- Part 7: Customize the admin form - reordering the fields [2.0/7.1.1]
- Part 7: Customize the admin form - split the form [2.0/7.1.2]
- Part 7: Adding related objects - register Choice with the admin [2.0/7.2.1]
- Part 7: Adding related objects - remove Choice from admin, add inline [2.0/7.2.2]
- Part 7: Adding related objects - use TabularInline (instead of StackedInline) [2.0/7.2.3]
- Part 7: Customize the admin change list - use list_display option [2.0/7.3.1]
- Part 7: Customize the admin change list - include was_published_recently() [2.0/7.3.2]
- Part 7: Customize the admin change list - add attributes to was_published_recently() [2.0/7.3.3]
- Part 7: Customize the admin change list - add list_filter [2.0/7.3.4]
- Part 7: Customize the admin change list - add search_fields [2.0/7.3.5]
- Part 7: Customize the admin look and feel - Customizing your project’s templates [2.0/7.4]
If you want to check out the code at a specific step, simply checkout the tag. E.g. if you are stook in "Part 6: Customize your app’s look and feel", do the following:
$ git clone git@github.com:consideratecode/django-tutorial-step-by-step.git
$ cd django-tutorial-step-by-step
$ git checkout 2.0/6.1
This repository does intentionally not contain:
__pycache__
directories containing Python bytecode- the file
db.sqlite3
containing the SQLite database
If you find any mistakes, open an issue or create a pull request. If you are unsure how to do that, drop me an email.
My goal is to stay true to the idea of one commit per step in the tutorial. This means that I will probably have to change tags and branch names if any changes are made.
Daniel Hepper daniel@consideratecode.com
The code in this repository originates from the Django tutorial, released as part of Django under the Modified BSD License by the Django Software Foundation and individual contributors. My original contribution to this repository is essentionally this README. For the full terms, see LICENSE.
The name "Django" is a registered trademark of the Django Software Foundation. Please note that any references to the official Django tutorial are nominative and should not imply affiliation with or endorsement by the Django Software Foundation.