Install Python
https://www.python.org/downloads/
Setting Environment Variable.
Install Git: https://git-scm.com/downloads
Install VSCode: https://code.visualstudio.com/
Install pip: https://pip.pypa.io/en/stable/installation/
Create new folder on your local computer/laptop.
Rightclick, Open gitbash
Open VSCode:
Code .
SELECT INTERPRETER venv
.venv\scripts\activate # this is from interpreter
python -m pip install --upgrade pip
.venv\Scripts\Activate.ps1
python -m pip install django
python -m django startproject nameyourprojectfolder .
python manage.py migrate
python manage.py runserver
In the VS Code Terminal, again with the virtual environment activated, run the development server with python manage.py runserver and open a browser to http://127.0.0.1:8000/
OUTPUT:
In the VS Code Terminal with your virtual environment activated, run the administrative utility's startapp command in your project folder (where manage.py resides):
python manage.py startapp hello
The command creates a folder called hello that contains a number of code files and one subfolder. Of these, you frequently work with views.py (that contains the functions that define pages in your web app) and models.py (that contains classes defining your data objects). The migrations folder is used by Django's administrative utility to manage database versions as discussed later in this tutorial. There are also the files apps.py (app configuration), admin.py (for creating an administrative interface), and tests.py (for creating tests), which are not covered here.
Modify hello/views.py to match the following code, which creates a single view for the app's home page:
from django.http import HttpResponse
def home(request):
return HttpResponse("Hello, Django!")
Create a file, hello/urls.py, with the contents below. The urls.py file is where you specify patterns to route different URLs to their appropriate views. The code below contains one route to map root URL of the app ("") to the views.home function that you just added to hello/views.py:
The project1 folder also contains a urls.py file, which is where URL routing is actually handled. Open project1/urls.py and modify it to match the following code (you can retain the instructive comments if you like). This code pulls in the app's hello/urls.py using django.urls.include, which keeps the app's routes contained within the app. This separation is helpful when a project contains multiple apps.
Save all modified files.
python manage.py runserver 8080
In the VS Code Terminal, again with the virtual environment activated, run the development server with python manage.py runserver and open a browser to http://127.0.0.1:8000/ to see a page that renders "Hello, Django".
Login
python manage.py createsuperuser
Once you execute above command, it will ask for
1. Username (which you needs to provide to login as admin). Give some name and enter.
2. Email address
3. Password
Now run server again and open http://127.0.0.1:8000/admin/