Skip to content

Commit a1b434f

Browse files
authored
Update Django tutorial (#6416)
1 parent c583f30 commit a1b434f

13 files changed

+50
-40
lines changed
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading

docs/python/tutorial-django.md

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,12 @@ To create a minimal Django app, then, it's necessary to first create the Django
124124
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:
125125
126126
```bash
127+
Watching for file changes with StatReloader
127128
Performing system checks...
128129
129130
System check identified no issues (0 silenced).
130-
131-
January 15, 2021 - 14:33:31
132-
Django version 3.1.5, using settings 'web_project.settings'
131+
June 13, 2023 - 18:38:07
132+
Django version 4.2.2, using settings 'web_project.settings'
133133
Starting development server at http://127.0.0.1:8000/
134134
Quit the server with CTRL-BREAK.
135135
```
@@ -206,15 +206,24 @@ You're probably already wondering if there's an easier way to run the server and
206206
207207
```json
208208
{
209-
"name": "Python: Django",
210-
"type": "python",
211-
"request": "launch",
212-
"program": "${workspaceFolder}/manage.py",
213-
"args": [
214-
"runserver",
215-
],
216-
"django": true
217-
},
209+
// Use IntelliSense to learn about possible attributes.
210+
// Hover to view descriptions of existing attributes.
211+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
212+
"version": "0.2.0",
213+
"configurations": [
214+
{
215+
"name": "Python: Django",
216+
"type": "python",
217+
"request": "launch",
218+
"program": "${workspaceFolder}\\manage.py",
219+
"args": [
220+
"runserver"
221+
],
222+
"django": true,
223+
"justMyCode": true
224+
}
225+
]
226+
}
218227
```
219228
220229
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
317326
1. Copy that line into the > prompt at the bottom of the debug console, and try changing the formatting:
318327
319328
```bash
320-
now.strftime("%a, %d %B, %Y at %X")
321-
'Fri, 07 September, 2018 at 07:46:32'
329+
now.strftime("%A, %d %B, %Y at %X")
330+
'Tuesday, 13 June, 2023 at 18:03:19'
322331
now.strftime("%a, %d %b, %Y at %X")
323-
'Fri, 07 Sep, 2018 at 07:46:32'
332+
'Tue, 13 Jun, 2023 at 18:03:19'
324333
now.strftime("%a, %d %b, %y at %X")
325-
'Fri, 07 Sep, 18 at 07:46:32'
334+
'Tue, 13 Jun, 23 at 18:03:19'
326335
```
327336
328337
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
388397
389398
```python
390399
def hello_there(request, name):
400+
print(request.build_absolute_uri()) #optional
391401
return render(
392402
request,
393403
'hello/hello_there.html',

0 commit comments

Comments
 (0)