Hello Readers!!! In this blog, we will see how to setup django development environment. But, at first we will see what is django and how we can install it. Django is a free and open-source web framework built with python and a framework is basically a collection of modules pre-written codes help with a particular task.
Steps to install and set up development environment
Step 1:Install python and pip
To install python, first we need to update the local APT repository. Open your terminal and input the below command. The -y
flag answers “yes” to prompts during the upgrade process.
sudo apt-get update
sudo apt-get -y upgrade
we can install Python 3 by using the below command.
sudo apt-get install python 3
To verify the successful installation of Python 3, we run a version check with the python 3 command:
python 3 -V
Now we need pip in order to install the packages from Python’s package repository.
sudo apt-get install -y python3-pip
To verify that pip was successfully installed, we run the below command:
pip3 -V
Step 2: Install virtualenv
virtualenv is a virtual environment where we can install software and Python packages in a contained development space.
To install virtualenv, we will use the below pip3 command:
pip3 install virtualenv
When it is install, we will run a version check to verify that the installation complete successfully:
virtualenv --version
Step 3: Install Django
We can install Django by using the below command
$ sudo apt install -y python3-Django
Once it is install, we will run a version check to verify that the installation complete successfully:
django-admin --version
Steps to Create a Django test Project
Step 1: Creating a Django test project
First we run the below command to create a directory called django-test-app
, or another name of your choice. Then we will navigate to that directory.
mkdir django-test-app
cd django-test-app

Inside the django-test-app
directory, we create our virtual environment. For e.g env and activate the virtual environment.
virtualenv env
. env/bin/activate

Step 2: Starting the Django-test-app project:
Now we can generate an application using django-admin
It is a command line utility for administration tasks in Python. Then we can use the startproject
command to create the project directory structure for our test website. In the django-test-apps
directory, we run the below command:
django-admin startproject test1
cd test1
ls

Step 3: Start and View your Website
Now we can start the server and view the website on a designated host and port by running the runserver
command.

Now we can visit localhost::8000 and check the output.

Conclusion:
In this blog, we saw what is django, how we can install it and how we can setup django application.