Django Installation and Setup
Installing and setting up Django is a straightforward process. Below are the step-by-step instructions to install Django and set up a new Django project on your system.
Prerequisites: Before installing Django, make sure you have Python installed on your system.
How to Install Django?
To Install Django in Linux and Mac is similar, here I am showing it in Windows for Linux and Mac just open the terminal in place of the command prompt and go through the following commands.
Step 1: Install Pip
Open the command prompt and enter the following command-
python -m pip install -U pip

Step 2: Set Virtual environment
Setting up the virtual environment will allow you to edit the dependency which generally your system wouldn't allow. Follow these steps to set up a virtual environment-
Step 3: Create virtual environment in Django
We should first go the directory where we want to create the virtual environment then we type the following command to create virtual environment in django.
python -m venv env_site

then we need to activate virtual environment in django
Step 4: Activate the virtual environment
Run the activation script located in the bin
directory within the virtual environment folder
- For Windows:
.\env_site\Scripts\activate.ps1
- For MacOs/Linux:
source env_site/bin/activate
Step 5: Install Django
Install django by giving following command
pip install django

Django Setup
Once Django is installed, we can start to create a new Django project.
Step 1: Start a new Django Project
Start a project by following command-
django-admin startproject geeks_site

Step 2: Navigate to the Project Directory
Change directory to geeks_site
cd geeks_site

Step 3: Start the server
Start the server by typing following command in cmd-
python manage.py runserver

Step 4: Verify Server Status
To check whether server is running or not go to web browser and enter http://127.0.0.1:8000/ as URL.