Skip to content

Commit d97d8c2

Browse files
committed
Update all refs to 5.1 -> 5.2 in the text
1 parent ab39720 commit d97d8c2

20 files changed

+53
-53
lines changed

chapter_01.asciidoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ You have 18 unapplied migration(s). Your project may not work properly until
227227
you apply the migrations for app(s): admin, auth, contenttypes, sessions.
228228
Run 'python manage.py migrate' to apply them.
229229
March 17, 2023 - 18:07:30
230-
Django version 5.1.4, using settings 'superlists.settings'
230+
Django version 5.2.4, using settings 'superlists.settings'
231231
Starting development server at http://127.0.0.1:8000/
232232
Quit the server with CONTROL-C.
233233
----

chapter_03_unit_test_first_view.asciidoc

+3-3
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ and the view part is actually provided by the templates,
282282
but you can see the general idea is there!
283283

284284
If you're interested, you can look up the finer points of the discussion
285-
https://docs.djangoproject.com/en/5.1/faq/general/#django-appears-to-be-a-mvc-framework-but-you-call-the-controller-the-view-and-the-view-the-template-how-come-you-don-t-use-the-standard-names[in the Django FAQs].
285+
https://docs.djangoproject.com/en/5.2/faq/general/#django-appears-to-be-a-mvc-framework-but-you-call-the-controller-the-view-and-the-view-the-template-how-come-you-don-t-use-the-standard-names[in the Django FAQs].
286286

287287
Irrespective of any of that, as with any web server, Django's main job is to
288288
decide what to do when a user asks for a particular URL on our site.
@@ -692,7 +692,7 @@ How can we write a test for URL resolution?
692692
At the moment we just test the view function directly by importing it and calling it.
693693
But we want to test more layers of the Django stack.
694694
Django, like most web frameworks, supplies a tool for doing just that, called the
695-
https://docs.djangoproject.com/en/5.1/topics/testing/tools/#the-test-client[Django Test Client].
695+
https://docs.djangoproject.com/en/5.2/topics/testing/tools/#the-test-client[Django Test Client].
696696

697697
// CSANAD: it might be a little confusing first why we add a _unit_ test, considering this second
698698
// test case is closer to a user's point of view. We could point out this to be one example
@@ -864,7 +864,7 @@ Let's go take a look:
864864
URL configuration for superlists project.
865865
866866
The `urlpatterns` list routes URLs to views. For more information please see:
867-
https://docs.djangoproject.com/en/5.1/topics/http/urls/
867+
https://docs.djangoproject.com/en/5.2/topics/http/urls/
868868
Examples:
869869
Function views
870870
1. Add an import: from my_app import views

chapter_04_philosophy_and_refactoring.asciidoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ Some people like to use another subfolder named after the app
399399
This is called "template namespacing".
400400
I figured it was overcomplicated for this small project, but it may be worth it on larger projects.
401401
There's more in the
402-
https://docs.djangoproject.com/en/5.1/intro/tutorial03/#write-views-that-actually-do-something[Django tutorial].]
402+
https://docs.djangoproject.com/en/5.2/intro/tutorial03/#write-views-that-actually-do-something[Django tutorial].]
403403

404404
[role="sourcecode"]
405405
.lists/templates/home.html (ch04l002)

chapter_05_post_and_database.asciidoc

+4-4
Original file line numberDiff line numberDiff line change
@@ -1052,9 +1052,9 @@ Django has many other field types, like `IntegerField`, `CharField`,
10521052
`DateField`, and so on. I've chosen `TextField` rather than `CharField` because
10531053
the latter requires a length restriction, which seems arbitrary at this point.
10541054
You can read more on field types in the Django
1055-
https://docs.djangoproject.com/en/5.1/intro/tutorial02/#creating-models[tutorial]
1055+
https://docs.djangoproject.com/en/5.2/intro/tutorial02/#creating-models[tutorial]
10561056
and in the
1057-
https://docs.djangoproject.com/en/5.1/ref/models/fields/[documentation].
1057+
https://docs.djangoproject.com/en/5.2/ref/models/fields/[documentation].
10581058

10591059

10601060

@@ -1694,7 +1694,7 @@ will render with multiple `<tr>` rows, one for each item in the variable
16941694
`items`. Pretty neat! I'll introduce a few more bits of Django template
16951695
magic as we go, but at some point you'll want to go and read up on the rest of
16961696
them in the
1697-
https://docs.djangoproject.com/en/5.1/topics/templates/[Django docs].
1697+
https://docs.djangoproject.com/en/5.2/topics/templates/[Django docs].
16981698

16991699
Just changing the template doesn't get our tests to green; we need to actually
17001700
pass the items to it from our home page view:
@@ -1762,7 +1762,7 @@ called 'db.sqlite3' in the base project directory:
17621762
----
17631763
[...]
17641764
# Database
1765-
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases
1765+
# https://docs.djangoproject.com/en/5.2/ref/settings/#databases
17661766
17671767
DATABASES = {
17681768
"default": {

chapter_07_working_incrementally.asciidoc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@ TIP: This is another place to pay attention to trailing slashes, incidentally.
11151115
// as we can have different methods on the same URL.
11161116
// Also, the way our Django app is configured, it will automatically redirect to a URL
11171117
// with the slash appended, so I'm not sure this makes much sense.
1118-
// https://docs.djangoproject.com/en/5.1/ref/settings/#append-slash
1118+
// https://docs.djangoproject.com/en/5.2/ref/settings/#append-slash
11191119

11201120
Try running that:
11211121

@@ -2352,7 +2352,7 @@ which is what we were trying to do anyway:
23522352
<1> There's our new form action.
23532353

23542354
<2> `.item_set` is called a
2355-
https://docs.djangoproject.com/en/5.1/topics/db/queries/#following-relationships-backward[reverse lookup].
2355+
https://docs.djangoproject.com/en/5.2/topics/db/queries/#following-relationships-backward[reverse lookup].
23562356
It's one of Django's incredibly useful bits of ORM that lets you look up an
23572357
object's related items from a different table.
23582358
((("reverse lookups")))

chapter_08_prettification.asciidoc

+4-4
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ It's defined in _settings.py_:
649649
[...]
650650
651651
# Static files (CSS, JavaScript, Images)
652-
# https://docs.djangoproject.com/en/5.1/howto/static-files/
652+
# https://docs.djangoproject.com/en/5.2/howto/static-files/
653653
654654
STATIC_URL = "static/"
655655
----
@@ -696,7 +696,7 @@ To get it to work, we need to change it to:
696696
====
697697

698698
// DAVID: Django best practice would be to use the static tag instead.
699-
// https://docs.djangoproject.com/en/5.1/howto/static-files/#configuring-static-files
699+
// https://docs.djangoproject.com/en/5.2/howto/static-files/#configuring-static-files
700700

701701
Now when `runserver` sees the request,
702702
it knows that it's for a static file because it begins with `/static/`.
@@ -729,7 +729,7 @@ That's because, although `runserver` automagically finds static files,
729729
Never fear, though:
730730
the Django developers have made an even more magical test class
731731
called `StaticLiveServerTestCase`
732-
(see https://docs.djangoproject.com/en/5.1/ref/contrib/staticfiles/#django.contrib.staticfiles.testing.StaticLiveServerTestCase[the docs]).
732+
(see https://docs.djangoproject.com/en/5.2/ref/contrib/staticfiles/#django.contrib.staticfiles.testing.StaticLiveServerTestCase[the docs]).
733733

734734
// JAN: Maybe you could mention that StaticLiveServerTestCase inherits from LiveServerTestCase - so all previous should work + static files. After reading the name, I imagined StaticLiveServerTestCase as some special test class for testing only static-related stuff
735735

@@ -1010,7 +1010,7 @@ making it relative to the location of the project base directory:
10101010
[source,python]
10111011
----
10121012
# Static files (CSS, JavaScript, Images)
1013-
# https://docs.djangoproject.com/en/5.1/howto/static-files/
1013+
# https://docs.djangoproject.com/en/5.2/howto/static-files/
10141014
10151015
STATIC_URL = "static/"
10161016
STATIC_ROOT = BASE_DIR / "static"

chapter_09_docker.asciidoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ System check identified no issues (0 silenced).
882882
883883
You have 19 unapplied migration(s). Your project may not [...]
884884
[...]
885-
Django version 5.1.4, using settings 'superlists.settings'
885+
Django version 5.2.4, using settings 'superlists.settings'
886886
Starting development server at http://127.0.0.1:8000/
887887
Quit the server with CONTROL-C.
888888
----

chapter_10_production_readiness.asciidoc

+6-6
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ $ *pip freeze*
298298
asgiref==3.8.1
299299
attrs==23.2.0
300300
certifi==2024.2.2
301-
django==5.1.4
301+
django==5.2.4
302302
gunicorn==21.2.0
303303
h11==0.14.0
304304
idna==3.6
@@ -326,7 +326,7 @@ Django, Gunicorn and Whitenoise:
326326
[subs="specialcharacters,quotes"]
327327
----
328328
$ *pip freeze | grep -i django*
329-
Django==5.1.[...]
329+
Django==5.2.[...]
330330
331331
$ *pip freeze | grep -i django >> requirements.txt*
332332
$ *pip freeze | grep -i gunicorn >> requirements.txt*
@@ -341,7 +341,7 @@ That should give us a requirements.txt file that looks like this:
341341
====
342342
[source,python]
343343
----
344-
django==5.1.4
344+
django==5.2.4
345345
gunicorn==21.2.0
346346
whitenoise==6.6.0
347347
----
@@ -459,7 +459,7 @@ _settings.py_ that we want to change for production:
459459
because that code might be visible to strangers.
460460
We'll want to generate a new, random one
461461
but then keep it the same for the foreseeable future
462-
(find out more in the https://docs.djangoproject.com/en/5.1/topics/signing/[Django docs]).
462+
(find out more in the https://docs.djangoproject.com/en/5.2/topics/signing/[Django docs]).
463463

464464
Development, staging and production sites always have some differences
465465
in their configuration.
@@ -641,7 +641,7 @@ By default, when DEBUG=True, `ALLOWED_HOSTS` effectively allows _localhost_,
641641
our own machine, so that's why it was working OK until now.
642642

643643
There's more information in the
644-
https://docs.djangoproject.com/en/5.1/ref/settings/#allowed-hosts[Django docs].
644+
https://docs.djangoproject.com/en/5.2/ref/settings/#allowed-hosts[Django docs].
645645

646646
The upshot is that we need to adjust `ALLOWED_HOSTS` in _settings.py_.
647647
Let's use another environment variable for that:
@@ -860,7 +860,7 @@ but it's more of shock to see that they are no longer appearing in the terminal
860860
If you're like me you might find yourself wondering if we really _did_ see them earlier
861861
and starting to doubt your own sanity.
862862
But the explanation is that Django's
863-
https://docs.djangoproject.com/en/5.1/ref/logging/#default-logging-configuration[default logging configuration]
863+
https://docs.djangoproject.com/en/5.2/ref/logging/#default-logging-configuration[default logging configuration]
864864
changes when DEBUG is turned off.
865865

866866
This means we need to interact with the standard library's `logging` module,

chapter_14_database_layer_validation.asciidoc

+6-6
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ But all is not quite as it seems,
150150
because _this test should already pass_.
151151

152152
If you take a look at the
153-
https://docs.djangoproject.com/en/5.1/ref/models/fields/#blank[docs for the Django model fields],
153+
https://docs.djangoproject.com/en/5.2/ref/models/fields/#blank[docs for the Django model fields],
154154
you'll see under _Field options_ that the default setting for _all_ fields is
155155
`blank=False`.
156156
Since TextField is a type of Field, it _should_ already disallow empty values.
@@ -289,7 +289,7 @@ Django models don't run full validation on save.
289289
((("full_clean method")))
290290
Django does have a method to manually run full validation, however,
291291
called `full_clean` (more info in
292-
https://docs.djangoproject.com/en/5.1/ref/models/instances/#django.db.models.Model.full_clean[the docs]).
292+
https://docs.djangoproject.com/en/5.2/ref/models/instances/#django.db.models.Model.full_clean[the docs]).
293293
Let's swap that for the `.save()` and see if it works:
294294

295295

@@ -559,7 +559,7 @@ self.assertContains(response, expected_error)
559559
====
560560

561561
...will show us the cause—Django has
562-
https://docs.djangoproject.com/en/5.1/ref/templates/builtins/#autoescape[HTML-escaped]
562+
https://docs.djangoproject.com/en/5.2/ref/templates/builtins/#autoescape[HTML-escaped]
563563
the apostrophe:
564564

565565
[subs="specialcharacters,macros"]
@@ -1225,7 +1225,7 @@ a [keep-together]#parameter#:
12251225
====
12261226

12271227
See the
1228-
https://docs.djangoproject.com/en/5.1/topics/http/urls/#reverse-resolution-of-urls[Django
1228+
https://docs.djangoproject.com/en/5.2/topics/http/urls/#reverse-resolution-of-urls[Django
12291229
docs on reverse URL resolution] for more info. We run the tests again, and check that they all pass:
12301230

12311231
[subs="specialcharacters,macros"]
@@ -1309,7 +1309,7 @@ AttributeError: 'List' object has no attribute 'get_absolute_url'
13091309
The implementation is to use Django's `reverse` function, which
13101310
essentially does the reverse of what Django normally does with _urls.py_
13111311
(see the
1312-
https://docs.djangoproject.com/en/5.1/topics/http/urls/#reverse-resolution-of-urls[docs]):
1312+
https://docs.djangoproject.com/en/5.2/topics/http/urls/#reverse-resolution-of-urls[docs]):
13131313

13141314

13151315
[role="sourcecode"]
@@ -1343,7 +1343,7 @@ def new_list(request):
13431343
====
13441344

13451345
There's more info in the
1346-
https://docs.djangoproject.com/en/5.1/topics/http/shortcuts/#redirect[Django docs].
1346+
https://docs.djangoproject.com/en/5.2/topics/http/shortcuts/#redirect[Django docs].
13471347
Quick check that the unit tests still pass:
13481348

13491349
[subs="specialcharacters,macros"]

chapter_15_simple_form.asciidoc

+2-2
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ and which fields we want it to use.
249249
like assigning sensible HTML form input types to different types of field,
250250
and applying default validation.
251251
Check out the
252-
https://docs.djangoproject.com/en/5.1/topics/forms/modelforms/[docs]
252+
https://docs.djangoproject.com/en/5.2/topics/forms/modelforms/[docs]
253253
for more info.
254254

255255
We now have some different-looking form HTML:
@@ -1208,7 +1208,7 @@ using a form is a nice way of encapsulating that logic.
12081208
// DAVID: I wonder if this is slightly missing the point.
12091209
// Our functional tests here are very high level - using a headless browser.
12101210
// But many developers use the Django test client
1211-
// (https://docs.djangoproject.com/en/5.1/topics/testing/tools/#the-test-client)
1211+
// (https://docs.djangoproject.com/en/5.2/topics/testing/tools/#the-test-client)
12121212
// for this kind of thing, which doesn't have browser validation built in.
12131213
// So we could use that if we really wanted to test the server side validation.
12141214
//

chapter_16_advanced_forms.asciidoc

+4-4
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ class Item(models.Model):
277277
====
278278

279279
You might want to take a quick peek at the
280-
https://docs.djangoproject.com/en/5.1/ref/models/options/[Django docs on model
280+
https://docs.djangoproject.com/en/5.2/ref/models/options/[Django docs on model
281281
`Meta` attributes] at this point.
282282

283283
// DAVID: Should we get them to run the tests to see they pass?
@@ -644,9 +644,9 @@ AssertionError: True is not false
644644

645645
The next step requires a little knowledge of Django's internals, but you
646646
can read up on it in the Django docs on
647-
https://docs.djangoproject.com/en/5.1/ref/models/instances/#validating-objects[model
647+
https://docs.djangoproject.com/en/5.2/ref/models/instances/#validating-objects[model
648648
validation] and
649-
https://docs.djangoproject.com/en/5.1/ref/forms/validation/[form validation].
649+
https://docs.djangoproject.com/en/5.2/ref/forms/validation/[form validation].
650650

651651
Django uses a method called `validate_unique`, both on forms and models, and
652652
we can use both, in conjunction with the `instance` attribute:
@@ -1114,7 +1114,7 @@ in our test:
11141114
// SEBASTIAN: If it's not too much of Django internals, maybe it's worth to mention
11151115
// how models instances are compared (or at least leave a link for curious readers)
11161116
// That said, if it wasn't shown before in the book
1117-
// https://docs.djangoproject.com/en/5.1/topics/db/queries/#comparing-objects
1117+
// https://docs.djangoproject.com/en/5.2/topics/db/queries/#comparing-objects
11181118
11191119
That works; we get a fully passing unit test suite:
11201120

chapter_17_javascript.asciidoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1432,7 +1432,7 @@ with the right selectors:
14321432
----
14331433
====
14341434
// DAVID: Really we should be using the static tag here.
1435-
// https://docs.djangoproject.com/en/5.1/howto/static-files/
1435+
// https://docs.djangoproject.com/en/5.2/howto/static-files/
14361436

14371437
Aaaand we run our FT:
14381438

chapter_19_spiking_custom_auth.asciidoc

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*******************************************************************************
66
77
🚧 This chapter has recently been updated for the third edition.
8-
Its listings now use Django 5.1 and Python 3.13.
8+
Its listings now use Django 5.2 and Python 3.13.
99
1010
Please send feedback! [email protected]
1111
@@ -236,7 +236,7 @@ The login in theory will be something like this:
236236
// "...and if so, we authorize/approve the request to authenticate/log in as the
237237
// associated user"
238238

239-
// https://docs.djangoproject.com/en/5.1/topics/auth/customizing/
239+
// https://docs.djangoproject.com/en/5.2/topics/auth/customizing/
240240

241241

242242
First let's prep an app for our accounts stuff:
@@ -345,7 +345,7 @@ with our 'base.html' in the real version.)
345345

346346
==== Email Server Config for Django
347347

348-
The https://docs.djangoproject.com/en/5.1/topics/email/[django docs on email]
348+
The https://docs.djangoproject.com/en/5.2/topics/email/[django docs on email]
349349
explain how `send_mail()` works, as well as how you configure it
350350
by telling Django what email server to use,
351351
and how to authenticate with it.
@@ -541,7 +541,7 @@ we need to sort out user authentication in Django.
541541
// reason behind it.
542542
The first thing we'll need is a user model.
543543
I took a dive into the
544-
https://docs.djangoproject.com/en/5.1/topics/auth/customizing[Django
544+
https://docs.djangoproject.com/en/5.2/topics/auth/customizing[Django
545545
auth documentation] and tried to hack in the simplest possible one:
546546

547547
[role="sourcecode"]
@@ -697,7 +697,7 @@ The `authenticate()` function invokes Django's authentication framework,
697697
which we configure using a "custom authentication backend",
698698
// CSANAD: why the quote marks? If it's because this is a reference to the
699699
// official Django docs, we could just make it a link instead to
700-
// https://docs.djangoproject.com/en/5.1/topics/auth/customizing/#writing-an-authentication-backend
700+
// https://docs.djangoproject.com/en/5.2/topics/auth/customizing/#writing-an-authentication-backend
701701
whose job it is to validate the UID and return a user with the right email.
702702

703703
We could have done this stuff directly in the view,

chapter_20_mocking_1.asciidoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ We'll use Django's "messages framework",
618618
which is often used to display ephemeral "success" or "warning" messages
619619
to show the results of an action.
620620
Have a look at the
621-
https://docs.djangoproject.com/en/5.1/ref/contrib/messages/[django messages docs]
621+
https://docs.djangoproject.com/en/5.2/ref/contrib/messages/[django messages docs]
622622
if you haven't come across it already.
623623

624624
Testing Django messages is a bit contorted--we have to pass `follow=True`

chapter_21_mocking_2.asciidoc

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ We call `django.contrib.auth.authenticate`, and then,
8383
if it returns a user, we call `django.contrib.auth.login`.
8484

8585
TIP: This is a good time to check out the
86-
https://docs.djangoproject.com/en/5.1/topics/auth/default/#how-to-log-a-user-in[Django docs on authentication]
86+
https://docs.djangoproject.com/en/5.2/topics/auth/default/#how-to-log-a-user-in[Django docs on authentication]
8787
for a little more context.
8888
((("Django framework", "documentation")))
8989

@@ -1538,7 +1538,7 @@ element: #id_logout; [...]
15381538

15391539
Implementing a logout URL is actually very simple:
15401540
we can use Django's
1541-
https://docs.djangoproject.com/en/5.1/topics/auth/default/#module-django.contrib.auth.views[built-in logout view],
1541+
https://docs.djangoproject.com/en/5.2/topics/auth/default/#module-django.contrib.auth.views[built-in logout view],
15421542
which clears down the user's session and redirects them to a page of our choice:
15431543

15441544
[role="sourcecode small-code"]

chapter_22_fixtures_and_wait_decorator.asciidoc

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class MyListsTest(FunctionalTest):
8686
primary key of the user object (which is actually the user's email address).
8787
// CSANAD: there is a different suggested way of importing SessionStore, using
8888
// the SESSION_ENGINE from the `settings`:
89-
// https://docs.djangoproject.com/en/5.1/topics/http/sessions/#using-sessions-out-of-views
89+
// https://docs.djangoproject.com/en/5.2/topics/http/sessions/#using-sessions-out-of-views
9090
//
9191
// Also, I would mention what the Django docs say about what the SessionStore is
9292
// or why it is useful ("when we need to use Django sessions manually, outside
@@ -216,7 +216,7 @@ as a way of temporarily keeping track of some state.
216216
This works for non–logged-in users too.
217217
Just use `request.session` inside any view, and it works as a dict.
218218
There's more information in the
219-
https://docs.djangoproject.com/en/5.1/topics/http/sessions/[Django docs on sessions].
219+
https://docs.djangoproject.com/en/5.2/topics/http/sessions/[Django docs on sessions].
220220
221221
**********************************************************************
222222

0 commit comments

Comments
 (0)