/django-in-action

Christopher Trudeau: The Django web application framework powers huge sites like Netflix, Dropbox, YouTube, and Spotify.

Primary LanguagePythonMIT LicenseMIT

Image

Sample Code and Exercise Solutions

This is the source code repository that goes along with the Django In Action book. Each chapter in the book adds new features to "RiffMates", a website for musicians seeking bands and bands seeking musicians.

As Django is a framework, individual code snippets don't tend to work on their own, they need to operate in the context of a Django project. To help understand how an example fits into the big picture, this repo contains multiple copies of the project in incremental stages. For example, the source code for chapter 3 is split into three directories: code/ch3a_templates, code/ch3b_inherit, and code/ch3c_exercises. The first two correspond to the examples on template basics and template inheritance, and the third contains the answers to the exercises at the end of the chapter. A full map is available below.

Electronic copies of the book include Appendix E, a complete listing of solutions to the exercises. Due to space constraints, printed copies do not include Appendix E, a PDF version is included in this repository for your reference.

Django In Action is available through the publisher as well as at your favourite book stores.

If you find errors in the code, feel free to open an issue. For those who participated in the early access program and internal review process, thanks so much for your feedback, it made a big difference.

Code Map

  • Chapter 2
    • ch02a_rocket -- Chapter 2.2, p29
    • ch02b_credits -- Chapter 2.7, p37
    • ch02c_exercises -- Chapter 2.8, p38
  • Chapter 3
    • 03a_templates -- Chapter 3.4, p44
    • 03b_inherit -- Chapter 3.8, p59
    • 03c_exercises -- Chapter 3.9. p63
  • Chapter 4
    • 04a_bands -- Chapter 4.2, p68
    • 04b_query -- Chapter 4.6, p81
    • 04c_page -- Chapter 4.6.3, p87
    • 04d_relationships -- Chapter 4.7, p89
    • 04e_exercises -- Chapter 4.11, p103
  • Chapter 5
    • 05a_admin -- Chapter 5.1, p105
    • 05b_customize -- Chapter 5.2, p113
    • 05c_search -- Chapter 5.2.1, p114
    • 05d_filter -- Chapter 5.2.2, p115
    • 05e_band -- Chapter 5.3, p119
    • 05f_exercises -- Chapter 5.4, p124
  • Chapter 6
    • 06a_userprofile -- Chapter 6.2, p131
    • 06b_signal -- Chapter 6.5, p142
    • 06c_exercises -- Chapter 6.7, p150
  • Chapter 7
    • 07a_forms -- Chapter 7.1, p153
    • 07b_modelforms -- Chapter 7.2, p162
    • 07c_editingforms -- Chapter 7.2.5, p172
    • 07d_staticfiles -- Chapter 7.3, p175
    • 07e_uploads -- Chapter 7.4, p178
    • 07f_exercises -- Chapter 7.5, p188
  • Chapter 8
    • 08a_tests -- Chapter 8.2, p194
    • 08b_exercises -- Chapter 8.9, p210
  • Chapter 9
    • 09a_commands -- Chapter 9.2, p219
    • 09b_options -- Chapter 9.3, p222
    • 09c_exercises -- Chapter 9.5, p229
  • Chapter 10
    • 10a_promoter -- Chapter 10.1, p232
    • 10b_famous -- Chapter 10.1.2, p236
    • 10c_fullname -- Chapter 10.2, p238
    • 10d_onlyfull -- Chapter 10.2, p244 (Listing 10.8)
    • 10e_birth -- Chapter 10.3, p243 (add birth)
    • 10f_death -- Chapter 10.3, p243 (add death)
    • 10g_squash -- Chapter 10.3, p243 (perform squashmigrations)
    • 10h_exercises -- Chapter 10.5, p 248
  • Chapter 11
    • 11a_ninja -- Chapter 11.2, p258
    • 11b_exercises -- Chapter 11.4, p281
  • Chapter 12
    • 12a_htmx -- Chapter 12.3, p286
    • 12b_exercises -- Chapter 12.6, p299
  • Chapter 13
    • 13a_power -- Chapter 13.1, p302