Scaffold for Django application web framework (Python) on Windows. A few steps to start coding with VsCode or VSCodium.
Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. Built by experienced developers, it takes care of much of the hassle of web development, so you can focus on writing your app without needing to reinvent the wheel. It’s free and open source.
Powershell & Project Directory
pwsh --version
PowerShell 7.3.4
pwd
Path
----
C:\codes\PYTHON\pyRepos\djangoVsCode
- VSCodium 'Binary releases of VS Code without MS branding/telemetry/licensing'
- Visual Studio Code 'see licese : https://code.visualstudio.com/License/'
- https://www.python.org/downloads/
- Now (june 23): python-3.12.0b1-amd64
Virtualenv is a tool to create isolated Python environments.
python -m venv C:\codes\PYTHON\pyRepos\djangoVsCode
c:/codes/PYTHON/pyRepos/djangoVsCode/Scripts/Activate.ps1
Python version
python --version
Python 3.11.1
Just deactivate on exit code session
pip install django
python -m django --version
4.2.1
django-admin startproject mysite
Step 1. Install following plugins
- Python (by microsoft)
- Live Server
Step 2. Set python version to your virtual env by following these steps in bullets in order
- Press
CTRL+SHIFT+P
This will open a command pallet in vscode. - Set the python version by selecting if it is visible in the dropdowns or by typing it like
Python > <path-to-venv>/bin/python
- create launch.json (normally it is automatically created when you press run button so first press run and see if it runs or not and then check or create launch.json)
- add this as contents of launch.json
exemple:
{
// Utilisez IntelliSense pour en savoir plus sur les attributs possibles.
// Pointez pour afficher la description des attributs existants.
// Pour plus d'informations, visitez : https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python : My Django",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/mysite/manage.py",
"args": [
"runserver",
"--noreload"
],
"django": true,
"justMyCode": true
}
]
}
Ctrl + C and :
python manage.py migrate
F5 again :
The install worked successfully! Congratulations!
Ctrl + C & make a requirements.txt
pip freeze > requirements.txt
type .\requirements.txt
asgiref==3.7.2
Django==4.2.1
sqlparse==0.4.4
tzdata==2023.3
If you want a .gitignore file
# Source file location (github .gitignore for python)
$source = 'https://raw.githubusercontent.com/github/gitignore/main/Python.gitignore'
# Destination to save the file (Your project)
$destination = 'C:\codes\PYTHON\pyRepos\djangoVsCode\.gitignore'
#Download the file
Invoke-WebRequest -Uri $source -OutFile $destination
... Hey wizards, do magic things now ;)