How to Install Django 3 on Ubuntu 18.04

Django is an open source web framework written in the Python programming language. Django’s strengths are rapid development, scalability, and reusability.

In this tutorial, we will install Django 3 for development environment on Ubuntu 18.04.

*0. Software Requirements*

Software requirements to install Django 3:

· Python 3 · pip 3 · virtualenv

*1.Install pip*

pip is the package manager for Python packages. With pip we install and manage the additional libraries and dependencies needed.

Install pip untuk Python 3.

[INPUT]

1 sudo apt install python3-pip -y

Verify pip installation.

[INPUT]

1 2 3 pip3 -V   pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)

*2.Install virtualenv*

virtualenv is a virtual environment intended for Python applications. By using virtualenv, each Python application project is isolated with the global environment of the operating system. Isolation of Python environment can prevent package conflicts between Python application projects and operating system environment.

Install virtualenv.

[INPUT]

1 2 3 sudo su pip3 install virtualenv exit

Verify virtualenv installation.

[INPUT]

1 2 3 virtualenv –version   16.7.8

*3.Install Django*

Install Django in virtualenv using pip.

Create django-apps directory.

[INPUT]

1 2 mkdir django-apps cd django-apps

Create a virtual environment with the name env.

[INPUT]

1 virtualenv env

Activate the virtual environment.

[INPUT]

1 source env/bin/activate

After activating the virtual environment, there is a (env) prefix as a sign that the virtual environment is active.

[INPUT]

1 (env) dev@django:~/django-apps$

Install Django using pip.

[INPUT]

1 pip install Django==3.0

Verify Django installation.

[INPUT]

1 2 3 django-admin –version   3.0

*4.Create Django Project*

Create a Django project with the name djangodemo.

[INPUT]

1 django-admin startproject djangodemo

Run Django development server.

[INPUT]

1 2 cd djangodemo python manage.py runserver  

The results of the command run the development server.

[INPUT]

1 2 3 Django version 3.0, using settings ‘djangodemo.settings’ Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C.

Development server runs on port 8000.

Browse http://127.0.0.1:8000.

To stop the development server press CTRL + C .

To deactivate the virtual environment, run the deactivate command.

[INPUT]

1 2 (env) dev@django:~/django-apps$ deactivate dev@django:~/django-apps$

Leave a Reply

Your email address will not be published.