Building Your First Django App: A Step-by-Step Tutorial

Posted: September 14, 2024 | Updated: September 14, 2024

Step 1: Create a folder and install Virtual Environment

Create a folder in your computer( Ex: My Django App) and open that folder in Code Editor like VS code (Right click and choose "Open with VS Code").

py -m venv venv

Note: Here "venv" is a virtual environment name. 

Step 2: Activate the Virtual Environment and install Django in a virtual environment

Activate the virtual environment using the following command

venv\Scripts\Activate.ps1

Then install the Django using the following command

pip install django 

Step 3: Create a main project and create a separate app

Create a main Django project using the following command

django-admin startproject main .

Note: Here "main" is the main project name. You can use the command without the dot "django-admin startproject main". Using the command without dot will create a folder with your main project name and add files with the same name inside the folder. 

Step 4: Connect the app with the main project and connect the separate app URLs to the main project

Step 5: Run the app.

Run the app using the following command

py manage.py runserver

Step 6: Create another separate app to add a Custom user model (if it's necessary) 

© 2024 Webapptiv. All rights reserved.