
Django is a Python web framework, so you need to have Python installed on your system. You can download Python from the official website, https://www.python.org/downloads/. When installation finish then follow these steps for Djnago installation:
1. Create virtual environment
Create a folder of your project and open it. Select address bar and type CMD and press ENTER. Command Prompt will open in that location.
My project name is Project in this case. Now create virtual environment using following command:
python -m venv venv
It is suggested to have a dedicated virtual environment for each Django project. When created, activate virual environment by using following code:
.\venv\Scripts\activate # Activate for Windows
source venv/bin/activate # Activate for Mac OS
Activated virtual environment looks like this:
Activate the virtual environment every time you open the command prompt to work on your project.
2. Install Django
pip install Django
This will give the following result:
Type following to upgrade
pip install --upgrade pip
Now Django is istalled successfully!
pip list command will give you the list of all the Python packages that have been installed in your virtual environment with versions.
If you want only Djnago version then use following command:
django-admin --version
3. Create Project
Decide a suitable name for your project then follow the code:
django-admin startproject mysite
cd mysite
python manage.py runserver
This will show following result:
Type 127.0.0.1:8000 in the address bar of browser and press ENTER.
You can see the folder Project and another folder named mysite
4. Create App
Apps in Django are designed to be modular and reusable, which means that they can be easily integrated into different projects. This allows developers to build complex web applications by combining different apps with different functionalities. Type the follwoing code to create an app:
python manage.py startapp main
App named main is created with its components like admin.py, apps.py, etc
Next topic Django CURD Application
Asif Shahzad | Full Stack Web Developer
Welcome to our Software Solutions Company, where we excel in transforming ideas into tangible realities. We have expertise in developing online management systems, website designing & development, software solutions, mobile app development, e-commerce solutions and graphic designing. We provide 24/7 services.