Skip to content

Update Django for VS Code Tutorial for Python 3.11 and Django 4.2 #6410

Closed
@dawnwages

Description

@dawnwages

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

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.
{
    // 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
        }
    ]
}
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'
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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions