Contents

How to Install or Upgrade Django Using Pip

14 Jul 2018 6 60  0
How to Install or Upgrade Django Using Pip
How to Install or Upgrade Django Using Pip

 

We will show you how to install or upgrade Django using pip on a Linux VPS. Django is a free and open-source web framework based on Python which follows the model-view-template (MVC) architectural pattern. Django is built by experienced web developers and encourages rapid development and clean, pragmatic design. Using Django, you can develop full-fledged database-driven websites in Python. The framework takes care of advanced tasks like user authentication, content administration, sitemaps, etc. Moreover, you can use clean and elegant URL schemes for your web application. Django is one of the most popular web server frameworks, and in this tutorial, we are going to show you how to install or upgrade Django using pip on a Linux VPS.

 

 

Prerequisites for Django

Django requires Python, so in order to run Django on your server, you need to install Python on your server. Python 3 is recommended. Also, you can use MySQL/MariaDB, PostgreSQL, or SQLite as a database engine alongside Django to store the data.

 

Connect to your Linux server via SSH

To install or update Django using pip, you need to have SSH access to the server. Connect to your server via SSH and make sure you have Python installed:

 

python -V

Or, if you are willing to use Python 3 for your Django project:

python3 -V

Install Django on a Linux VPS

First of all, you have to install pip on your server. To install pip on a Ubuntu 16.04 VPS, run the following commands:

apt-get update

apt-get install python3-pip

CentOS 7 comes with Python 3.4 by default, so to install pip on a CentOS 7 VPS, run the following command:

yum install python34-pip

In case you already have pip installed on your Linux server, you can upgrade it using the following commands:

On Ubuntu 16.04, run the following command:

 

pip3 install --upgrade pip

On CentOS 7, run the following command:

 

pip3.4 install --upgrade pip

The next step is to install and set up the Python Django package:

 

On Ubuntu 16.04, run the following command:

 

pip3 install django

On CentOS 7, run the following command:

 

pip3.4 install django

Now you have the Django package installed on your server. You can start a new Django project using the django-admin command. For example:

 

django-admin startproject newapp

The command will generate a new Django application called newapp, which you can use for your next project. For more information about how to get started with Django, it is recommended that you refer to the official Django documentation.

 

Update Django using pip on a Linux VPS

First, you should determine which Django version is currently installed on your server.

 

On Ubuntu 16.04, run the following command:

 

pip3 list | grep -i django

On CentOS 7, run the following command:

 

pip3.4 list | grep -i django

If you want to update the Django package using pip on your Linux server, you can use the following commands:

 

On Ubuntu 16.04:

 

pip3 install --upgrade django

On CentOS 7:

 

pip3.4 install --upgrade django

Also, pip allows you to install a specific Django version. You can do so by specifying the Django version while installing/upgrading the package. For example, to install Django 1.11.12, which is the latest release from the 1.11 LTS release, you can run the following:

 

On Ubuntu 16.04, run the following command:

 

pip3 install django==1.11.12

Or, if you are upgrading to that version, run the following command:

 

pip3 install --upgrade django==1.11.12

On CentOS 7, run the following command:

 

pip3.4 install django==1.11.12

Or, if you are upgrading to that version, run the following command:

 

pip3.4 install --upgrade django==1.11.12

As you can see, installing and upgrading Django using pip on a Linux server is a very easy task. You have to install Python and pip on the server and then install the Django package, which will allow you to use the django-admin command to start new Django projects. If you wish to uninstall the Django package completely, you can use the following commands:

 

On Ubuntu 16.04, run the following command:

 

pip3 uninstall django

On CentOS 7, run the following command:

 

pip3.4 uninstall django

This will not remove any of your existing projects. It will only remove the Django package installed by pip.

0 Comments
Add a comment

Leave a Reply