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.
1 | sudo apt install python3-pip -y |
Verify pip installation.
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.
1 2 3 | sudo su pip3 install virtualenv exit |
Verify virtualenv installation.
1 2 3 | virtualenv --version 16.7.8 |
3.Install Django
Install Django in virtualenv using pip.
Create django-apps directory.
1 2 | mkdir django-apps cd django-apps |
Create a virtual environment with the name env.
1 | virtualenv env |
Activate the virtual environment.
1 | source env/bin/activate |
After activating the virtual environment, there is a (env) prefix as a sign that the virtual environment is active.
1 | (env) dev@django:~/django-apps$ |
Install Django using pip.
1 | pip install Django==3.0 |
Verify Django installation.
1 2 3 | django-admin --version 3.0 |
4.Create Django Project
Create a Django project with the name djangodemo.
1 | django-admin startproject djangodemo |
Run Django development server.
1 2 | cd djangodemo python manage.py runserver |
The results of the command run the development server.
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.
1 2 | (env) dev@django:~/django-apps$ deactivate dev@django:~/django-apps$ |
If you found this article helpful and would like to support my work, consider making a donation through PayPal. Your support helps me continue creating useful content and tutorials. Thank you!
Donate via PayPal: https://paypal.me/musaamin