D j a n g o is a popular python web framework for developing dynamic website and application. By using Django you can easily create web applications. To know more about Django please go through What is Django and Why Django? An Introduction to Django Now this document help you through installing Django.
There are different ways to install Django
- Global install from package
- Install with pip in a virtual environment
- Install with git
Here we install Django using the pip. After the installation you can create your own project. Now lets start.
Install Python
Django is a Python web framework, thus requiring Python to be installed on your machine. To install Python on your machine please go through download Python. Now we can install Python through command prompt. If you have launched a new server, then we recommend to update the server with below command
sudo apt-get update
Django software foundation is recommended to user Python3 , so once everything is updated we can install Python3 by using the following command.
sudo apt-get install python3
To check the successful installation of python3 run th e version check command
python3 -V
Output
Python 3.6.9
Next, install the pip from the Ubuntu repositories using the following command
sudo apt install python3-pip
Once the successful installation of pip you can use it to install the venv package
sudo apt install python3-venv
When ever you start a new project, you can create a new virtual environment for it. Execute the following command to create virtual environment
python3 -m venv env1
Here env1 consider as your virtual environment, but you should name it something meaningful always. Now a directory named env1 will be created on your machine where ever your location you execute the above command. After the virtual environment is created you can activate it by using the following command.
source env1/bin/activate
Now your prompt will be updated something like this
(env1)username@hostname:~/current_directory$
After creating virtual environment you can install Django using pip
pip install django
You can verify the installation by using the following command
django-admin --version
Output
Note: Your version may be differ from the version shown here.
2.2
At the end
Now you have the latest version of Django in your virtual environment, providing the main tools you need to create powerful web applications. If you have any feedback or queries regarding the Django installation tutorial you can simply note it down in the comment section.