How To Install Django on Ubuntu
Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design which follows the model-view-template (MVT) architectural pattern. Built by experienced developers, it takes care of much of the hassle of Web development, so you can focus on writing your app without needing to reinvent the wheel. It’s free and open source. So today how I tell you How To Install Django on Ubuntu.
It is maintained by the Django Software Foundation (DSF), an independent organization established as a 501(c)(3) non-profit. Django’s primary goal is to ease the creation of complex, database-driven websites. The framework emphasizes reusability and “pluggability” of components, less code, low coupling, rapid development, and the principle of don’t repeat yourself. Python is used throughout, even for settings files and data models. Django also provides an optional administrative create, read, update and delete interface that is generated dynamically through introspection and configured via admin models.
You may like also: ExpressJS – Web framework for Node.js
Some well-known sites that use Django include the Public Broadcasting Service, Instagram, Mozilla, The Washington Times, Disqus, Bitbucket, and Nextdoor. It was used on Pinterest, but later the site moved to a framework built over Flask.
How To Install Django on Ubuntu
There Are some methods for installing Django:
- Global install from packages: The official Ubuntu repositories contain Django packages that can be installed with the conventional
aptpackage manager. This is simple, but not as flexible as some other methods. Also, the version contained in the repositories may lag behind the official versions available from the project.
- Install with
pipin a virtual environment: You can create a self-contained environment for your projects using tools like
virtualenv. A virtual environment allows you to install Django in a project directory without affecting the larger system, along with other per-project customizations and packages. This is typically the most practical and recommended approach to working with Django.
- Development version install with
git: If you wish to install the latest development version instead of the stable release, you can acquire the code from the Git repo. This is necessary to get the latest features/fixes and can be done within your virtual environment. Development versions do not have the same stability guarantees as more stable versions, however.
We will be installing django in an isolated environment but why? simple because we do not want django packages to mess with os python libraries, we will be using pip to install packages and virtualenv to create virtual environments.pip is a package management system used to install and manage software packages written in Python.
Install python3 Pip
sudo apt-get install python3-pip
sudo pip3 install virtualenv
Create new directory for your project
mkdir -p Code/Django/myapp
Create new Virtual Environment we will call it py3,
Once you run above command new directory py3 will be created. Now We need to activate our new py3 environment
your prompt will be changed to
Now Install Django. Notice we are not running pip3 command, we will just run pip inside virtualenv
pip install django
Once Django is installed, you can check the version by
Lets start new project call firstproject
django-admin startproject firstproject
Lets start new app blog
python manage.py startapp blog
Now we will start the server
python manage.py runserver
Finally done, Whenever you want to leave the virtual environment just run to
Dont forget to run this command Every time you want to work with your Django app
You may like also:
- How To Create Secure MQTT Broker
- How To Enable Free HTTPS on your website
- How To Install Node.js on Ubuntu
- How to install MongoDB in ubuntu
- How to Install InfluxDB on Ubuntu
- What is Jinja
- How to Install PyCharm on Ubuntu
2 thoughts on “How To Install Django on Ubuntu”
Pingback: Linux Basic Commands | File System Hierarchy Standard | Linux Tutorials
Pingback: What Is Chatbot ? - IoTbyHVM - Explore TechBytes