Description
Tutorial url: https://code.visualstudio.com/docs/python/tutorial-django
Entire tutorial works for updated versions:
Python v2023.10.0
Pylance v2023.6.10
Python 3.11
pip 23.1.2
Django 4.2.2
-
Create a project environment for the django tutorial section 5: Update screenshot for selecting an interpreter to include Python 3.11.
-
Create a project environment for the django tutorial section 7: Update screenshot to Python 3.11
-
Create the Django Project Section 3: Update the runserver console response to more recent date and time.
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
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.
-
Create the Django Project Section 4: Update the screenshot from Django 3.1 to 4.2
-
Create the debugger launch profile Section 3: The launch.json file is a little different than what is in the tutorial.
{
// 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
}
]
}
-
Explore the debugger section 4 update the status bar image:
-
Explore the debugger step 8 and 9: Update the strf time:
now.strftime("%A, %d %B, %Y at %X")
'Tuesday, 13 June, 2023 at 18:03:19'
now.strftime("%a, %d %b, %Y at %X")
'Tue, 13 Jun, 2023 at 18:03:19'
now.strftime("%a, %d %b, %y at %X")
'Tue, 13 Jun, 23 at 18:03:19'
-
Explore the debugger step 10: Update Edge image:
-
Explore the debugger in the tip we recommend print the URI in view, we could include that in the code
print(request.build_absolute_uri()
-
Use a template to render a page section 5: keep print URI in code snippet
def hello_there(request, name):
print(request.build_absolute_uri())
return render(
request,
'hello/hello_there.html',
{
'name': name,
'date': datetime.now(),
}
)
Suggestion: In order to include admin.py
and createsuperuser
I would remove the form.py
approach which isn't gone into detail much, and instead:
- create superuser
- check admin
- go to terminal
from hello.models import LogMessage
- check all messages
all_messages = LogMessage.objects.all()
and perhaps test methods on query string like.all()
,.last()
,.create()
eg.m = LogMessage.create(field1='result', field2='result')
m.save()
then check admin again. .filter()
and view on your template.- bonus points for if we can show off some type of UI in the template to inspect those variables.