Django is a free and open-source high-level Python web framework that encourages developers to develop fully-featured Python Web Applications. Using Django you can build secure, scalable and maintainable web applications.
Django framework wrote a well structured that helps to do quickly create Python web applications. It provides higher security for the application and avoids developers for making many common security mistakes.
There are different methods to install the Django framework on Ubuntu:
- Install Django with pip in a virtual environment
- Django install from packages
- Install Django from GitHub Repo
In this tutorial, we are going to install Django on Ubuntu 18.04 using Python Virtual Environment. The best thing to use Python virtual environments is to create an isolated environment for different Python projects.
Here is a step by step instructions for how to install Django in a Python virtual environment on Ubuntu 18.04. Before we start to install Django on Ubuntu 18.04 you must have the non-root user with sudo privileges.
Prerequisites
First, Install tree package to better understand on our further tutorial.
sudo apt install tree
Install Python 3
Python 3.6 by default installed in Ubuntu 18.04. You can verify the Python 3 is installed in your system using the following command.
python3 -v
The output should look like below. Please note that the version number may vary.
Python 3.6.8
Install pip3 Package
Next, Install pip package from the Ubuntu repositories.
sudo apt install python3-pip
Install virtualenv modules
sudo pip3 install virtualenv
Create and Activate Virtual Environment
mkdir django_app && cd django_app
python3 -m virtualenv env_name
source env_name/bin/activate
Install Django
pip install Django
Create First Django Project
django-admin startproject firstapp
That all you need to know how to create a Python virtual environment. Furthermore, we are going through step by step Django installation in Ubuntu 18.04. Even more, we see how to migrate the database, and create a superuser for Django.
Top comments (0)