Skip to content

rnek0/DjangoApp

Repository files navigation

DjangoApp

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

Install VsCode or VSCodium

Install Python

Install virtualenv

Virtualenv is a tool to create isolated Python environments.

Install

Create venv

python -m venv C:\codes\PYTHON\pyRepos\djangoVsCode

Activate venv

c:/codes/PYTHON/pyRepos/djangoVsCode/Scripts/Activate.ps1

Python version

python --version
Python 3.11.1  

Deactivate

Just deactivate on exit code session

Install Django

pip install django
python -m django --version
4.2.1

Creation django app

django-admin startproject mysite

Configure VSCode to serve app

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

  1. Press CTRL+SHIFT+P This will open a command pallet in vscode.
  2. Set the python version by selecting if it is visible in the dropdowns or by typing it like Python > <path-to-venv>/bin/python
  3. 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)
  4. add this as contents of launch.json

thx: noobsnoob.blogspot.com

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
    }
  ]
}

F5

Migrations

Ctrl + C and :

python manage.py migrate

Migrate

Migrate

F5 again :

It works

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

Wanna just docs ?

Coding

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 ;)

About

Scaffold for Django application web framework (Python) on Windows. A few steps to start coding with VsCode or VSCodium.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published