From 7eca33ece71c535b331f3ab69e4079f0ad9851c9 Mon Sep 17 00:00:00 2001 From: Luciana Abud Date: Fri, 16 Jun 2023 17:14:28 -0700 Subject: [PATCH] Update Django tutorial --- .../django-tutorial/app-in-browser-01.png | 4 +- .../django-tutorial/debug-continue-arrow.png | 4 +- .../django-tutorial/debug-local-variables.png | 4 +- .../django-tutorial/debug-program-paused.png | 4 +- .../django-tutorial/debug-run-result.png | 4 +- .../django-tutorial/debug-status-bar.png | 4 +- .../django-empty-project-success.png | 4 +- .../django-tutorial/peek-definition.png | 4 +- .../django-tutorial/template-debugger.png | 4 +- docs/python/images/shared/debug-toolbar.png | 4 +- .../shared/environment-in-status-bar.png | 4 +- .../shared/select-virtual-environment.png | 4 +- docs/python/tutorial-django.md | 42 ++++++++++++------- 13 files changed, 50 insertions(+), 40 deletions(-) diff --git a/docs/python/images/django-tutorial/app-in-browser-01.png b/docs/python/images/django-tutorial/app-in-browser-01.png index 021b25d317..17852e79f6 100644 --- a/docs/python/images/django-tutorial/app-in-browser-01.png +++ b/docs/python/images/django-tutorial/app-in-browser-01.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:906248fd2114354be9d6402788ce78e67840c1b57eb04e0e38e052724eeaa624 -size 2639 +oid sha256:582a53c0ea7042f5e5d9db5ba6280fa8b817d8a2968ba8bf5d713d8325ff2101 +size 142363 diff --git a/docs/python/images/django-tutorial/debug-continue-arrow.png b/docs/python/images/django-tutorial/debug-continue-arrow.png index ac338abbf1..186d60b947 100644 --- a/docs/python/images/django-tutorial/debug-continue-arrow.png +++ b/docs/python/images/django-tutorial/debug-continue-arrow.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7faa37082010816f0282b6687e20dffa8c529c9e349d6671b504c3501c36e4bd -size 1064 +oid sha256:09ebd0a2eb4af038585ece8edaf9f82ff493e453e7eaf70efd3736675f8200dd +size 9163 diff --git a/docs/python/images/django-tutorial/debug-local-variables.png b/docs/python/images/django-tutorial/debug-local-variables.png index ba4a3cb3f1..2f713904f8 100644 --- a/docs/python/images/django-tutorial/debug-local-variables.png +++ b/docs/python/images/django-tutorial/debug-local-variables.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3112866076a2ba6cde50792b9e8047046c640fd1d3b2fb291bc2076fd6744c29 -size 5003 +oid sha256:0b51b20b33a7b19d5584a1eeb8b77a5b52585ccdfb7c7e8697ef937eaeea9242 +size 58368 diff --git a/docs/python/images/django-tutorial/debug-program-paused.png b/docs/python/images/django-tutorial/debug-program-paused.png index 08fbf7c839..776fcd2b6d 100644 --- a/docs/python/images/django-tutorial/debug-program-paused.png +++ b/docs/python/images/django-tutorial/debug-program-paused.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d1d72d6dcd7471d1d50aab8fe998f70e54106b7a023d8dccf160ac67fd96297b -size 7092 +oid sha256:284335de7b2f85d09e5728f513bbfc628e7c2c82e259a4e009ec63c3191102bb +size 66182 diff --git a/docs/python/images/django-tutorial/debug-run-result.png b/docs/python/images/django-tutorial/debug-run-result.png index e1c7b8e836..78a4421129 100644 --- a/docs/python/images/django-tutorial/debug-run-result.png +++ b/docs/python/images/django-tutorial/debug-run-result.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4cb5d13989a77cbfe0a49040ae8173d2c8f4d46118a0ef7a2d0fabe4b7f8bda0 -size 3958 +oid sha256:2373c9f3b18378131b5751699237909dbc842e34c7a5c686781bce917283d004 +size 247378 diff --git a/docs/python/images/django-tutorial/debug-status-bar.png b/docs/python/images/django-tutorial/debug-status-bar.png index 9c379e75a2..47f6a81a0f 100644 --- a/docs/python/images/django-tutorial/debug-status-bar.png +++ b/docs/python/images/django-tutorial/debug-status-bar.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2b79b0521b554774b9c25a40c46a531ee2c640154e88097ba2f6937c3bda7009 -size 1684 +oid sha256:621dbf75457280ceea4ae0e08e27e7d7dcf0fa628d12568985b4bf75d7ef4fef +size 28292 diff --git a/docs/python/images/django-tutorial/django-empty-project-success.png b/docs/python/images/django-tutorial/django-empty-project-success.png index f19f913f70..e67ce88f69 100644 --- a/docs/python/images/django-tutorial/django-empty-project-success.png +++ b/docs/python/images/django-tutorial/django-empty-project-success.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:83be4c1d6d3f8c1f036203f1cf995a5201e8d0176f101efb7c8836f574f1a2ac -size 14391 +oid sha256:c2d7f762d762c8a523af1d7a446ceb15f2cbcae88a566c1761f746c2eff8e788 +size 139539 diff --git a/docs/python/images/django-tutorial/peek-definition.png b/docs/python/images/django-tutorial/peek-definition.png index 26b1195750..ec16628ec2 100644 --- a/docs/python/images/django-tutorial/peek-definition.png +++ b/docs/python/images/django-tutorial/peek-definition.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:819b4416fdb0c2649bfcb6d8e68667f3c9c894b6202da834ae76752b346aa34f -size 11908 +oid sha256:30a5e5e2690bf403f88eff3f00d37945fa890d259876c84716262be9429d6877 +size 243324 diff --git a/docs/python/images/django-tutorial/template-debugger.png b/docs/python/images/django-tutorial/template-debugger.png index a3c0bed7c2..23e978af11 100644 --- a/docs/python/images/django-tutorial/template-debugger.png +++ b/docs/python/images/django-tutorial/template-debugger.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5cb56b3398ea16b9cd529c6a71f75f2675f20e182d763df3d7675c74db0ee725 -size 14986 +oid sha256:44fda28a3476fd0faa30f1b62793c6d9091605328e9dff92f4a8ed1ef6fa7625 +size 308308 diff --git a/docs/python/images/shared/debug-toolbar.png b/docs/python/images/shared/debug-toolbar.png index 5bdce26064..5d905061de 100644 --- a/docs/python/images/shared/debug-toolbar.png +++ b/docs/python/images/shared/debug-toolbar.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5fe5a1a0db6b1bc0086ac2b48fd679d02a903c1fd0eb36092481a1b7ad174699 -size 399 +oid sha256:428b948d113de8ac325da2778836fde2a3298fd7f21cdf20b6a0e004b5641dbb +size 2060 diff --git a/docs/python/images/shared/environment-in-status-bar.png b/docs/python/images/shared/environment-in-status-bar.png index b2d6272ae7..51d8e31f82 100644 --- a/docs/python/images/shared/environment-in-status-bar.png +++ b/docs/python/images/shared/environment-in-status-bar.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9149e0af1b253e1e0ce63dbc2bbb750dccfdeb244958655ac840ba16a8072cc1 -size 5167 +oid sha256:e22ff963cc8c9e5d44d16912c0196641acb77846a44e1f7c6c8f77cbcc503d58 +size 7875 diff --git a/docs/python/images/shared/select-virtual-environment.png b/docs/python/images/shared/select-virtual-environment.png index 1bfb06fac2..1561de6d3d 100644 --- a/docs/python/images/shared/select-virtual-environment.png +++ b/docs/python/images/shared/select-virtual-environment.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c65964ed10ebaa450eb1326d0c84889ddf87ea1e56988b6ae11af3b2e237c50c -size 97192 +oid sha256:6ac38f51c4954ee2e27753107e134fd8ca01838016ab1ed50081b3a3d597b411 +size 34288 diff --git a/docs/python/tutorial-django.md b/docs/python/tutorial-django.md index b26cb8086e..f67734dd34 100644 --- a/docs/python/tutorial-django.md +++ b/docs/python/tutorial-django.md @@ -124,12 +124,12 @@ To create a minimal Django app, then, it's necessary to first create the Django 1. To verify the Django project, make sure your virtual environment is activated, then start Django's development server using the command `python manage.py runserver`. The server runs on the default port 8000, and you see output like the following output in the terminal window: ```bash + Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). - - January 15, 2021 - 14:33:31 - Django version 3.1.5, using settings 'web_project.settings' + June 13, 2023 - 18:38:07 + Django version 4.2.2, using settings 'web_project.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CTRL-BREAK. ``` @@ -206,15 +206,24 @@ You're probably already wondering if there's an easier way to run the server and ```json { - "name": "Python: Django", - "type": "python", - "request": "launch", - "program": "${workspaceFolder}/manage.py", - "args": [ - "runserver", - ], - "django": true - }, + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python: Django", + "type": "python", + "request": "launch", + "program": "${workspaceFolder}\\manage.py", + "args": [ + "runserver" + ], + "django": true, + "justMyCode": true + } + ] + } ``` This configuration tells VS Code to run `"${workspaceFolder}/manage.py"` using the selected Python interpreter and the arguments in the `args` list. Launching the VS Code debugger with this configuration, then, is the same as running `python manage.py runserver` in the VS Code Terminal with your activated virtual environment. (You can add a port number like `"5000"` to `args` if desired.) The `"django": true` entry also tells VS Code to enable debugging of Django page templates, which you see later in this tutorial. @@ -317,12 +326,12 @@ Debugging gives you the opportunity to pause a running program on a particular l 1. Copy that line into the > prompt at the bottom of the debug console, and try changing the formatting: ```bash - now.strftime("%a, %d %B, %Y at %X") - 'Fri, 07 September, 2018 at 07:46:32' + now.strftime("%A, %d %B, %Y at %X") + 'Tuesday, 13 June, 2023 at 18:03:19' now.strftime("%a, %d %b, %Y at %X") - 'Fri, 07 Sep, 2018 at 07:46:32' + 'Tue, 13 Jun, 2023 at 18:03:19' now.strftime("%a, %d %b, %y at %X") - 'Fri, 07 Sep, 18 at 07:46:32' + 'Tue, 13 Jun, 23 at 18:03:19' ``` 1. Step through a few more lines of code, if you'd like, then select Continue (`kb(workbench.action.debug.continue)`) to let the program run. The browser window shows the result: @@ -388,6 +397,7 @@ In this section, you start by creating a single page using a template. In subseq ```python def hello_there(request, name): + print(request.build_absolute_uri()) #optional return render( request, 'hello/hello_there.html',