loader image

21CS62 Program 2

2. Creation of virtual environment, Django project and App should be demonstrated.

Here are the steps you can follow to create virtual environment:

Step-01: Create a new folder for your project in any location.
Step-02: Open that created folder in the Visual Studio Code.
Step-03: Open the VS Code integrated terminal.

VS Code

Step-04: Create a virtual environment:-
⦿ In the terminal, run the below command to create a new virtual environment.

python -m venv env
VS Code

Step-05: Activate the virtual environment:-
⦿ In the terminal, run the below command to activate the virtual environment.

env\Scripts\activate
VS Code

Step-06: Install Django:-
⦿ Run the below command to install Django.

pip install django
VS Code

Step-07: Create a new Django project:-
⦿ Run the below command to create Django project.

django-admin startproject project
VS Code

Step-08: After creating Django project change the directory using below command.

cd project

Step-09: Create a new Django app:-
⦿ After changing the directory create a Django app using below command.

python manage.py startapp firstapp
VS Code

Step-10: Add the app to the installed_apps list:-
⦿ locate the settings.py file (usually located in the project directory) and open it.
⦿ After then add your app name in install_apps list as per below image.

VS Code

Step-11: Run Your Project:-
⦿ Now setup is completed you can run your project using below command.
⦿The terminal will display the URL where the development server is running, typically http://127.0.0.1:8000/.
⦿ Copy the URL from the terminal and paste it into your web browser’s address bar to see the output of web page.

python manage.py runserver
VS Code
VS Code

Leave a Reply

Your email address will not be published. Required fields are marked *