Table of contents
1.
Introduction 
2.
Python Installation
3.
Django Installation
3.1.
Django Installation in Ubuntu
3.2.
Verifying Django Installation in Ubuntu
3.3.
Django Installation in Windows
3.4.
Verifying Django Installation in Windows
4.
Database Setup
5.
Web Server
6.
Launch Django App
7.
Frequently Asked Questions
8.
Key Takeaways
Last Updated: Mar 27, 2024

Django Installation

Author Hari Sapna Nair
2 upvotes
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction 

Django is a high-level web framework that helps develop highly maintainable and secure websites. The primary goal of Django is to ease the creation of complex database-driven websites. It helps eliminate repetitive tasks and makes the development process an easy task. Due to its rapid development feature, Django is a widely used web framework. 

 

To know more about Django, check out the blog Getting started with Django.


In this blog, we will discuss the Django Installation process. The Django development environment involves installing and setting up Python, Django, and a Database System. Since Django deals with web applications, we also need a web server setup.

Python Installation

As Django is written in python, we will need to install python on the system. Python will probably be installed on the latest Linux or Mac OS distributions. To verify if python is installed type, the python command on the terminal.
 

Verifying if python is installed on Ubuntu
 

Otherwise, one can download and install the latest python version from the following link: http://www.python.org/download.

Django Installation

To download Django, visit https://www.djangoproject.com/download/, where various options to download Django will be available. Django requires pip,  a package management system used to install and manage packages written in python to start the installation.

Django Installation in Ubuntu

Before Django installation, make sure pip is installed in the local system. Then install the required version with pip:

pip install django==3.2.10

Verifying Django Installation in Ubuntu

After installing Django, we need to verify the Django installation. For this, open the terminal and write python3, and press enter. It will display a python shell where we can verify the Django installation.
 

Verifying Django installation on Ubuntu

Django Installation in Windows

Django installation is effortless in python using pip. In the command prompt, execute the following command: 

pip install django

Verifying Django Installation in Windows

After the installation has been completed, we can verify the Django installation by executing the following command in the command prompt:

 

Verifying Django installation on Windows

Database Setup

Django supports various database engines, and we can set up any of them based on our requirements after referring to the respective documentation.

Web Server

Django comes along with a lightweight web server for developing and testing applications. This server is pre-configured to work with Django, and it restarts whenever we modify the code.
 

However, Django does support Apache and other popular web servers such as Lighttpd

Launch Django App

For this, create a new Django project using the following command:

django-admin startproject djangoApp

 

Here djangoApp is the name of the project.

 

Now let's verify if the Django project works. For that change into the djangoApp directory, and run the following command:

python3 manage.py runserver

 

The following output is seen on the terminal:

Output

 

We have started the Django development server, a lightweight web server written in python. Now that the server's running, let us visit http://127.0.0.1:8000/

 

http://127.0.0.1:8000/

 

Frequently Asked Questions

1. Which version of python has to be installed to support Django?

Ans:- The Latest Django version requires python 2.6.5 or higher to function properly.

 

2. How can we get the latest development version of Django?

Ans:- The latest Django version is the one that's in our Git repository. This is mostly for experienced users who want to try incoming changes and help identify bugs before an official release. To get this, use the following shell command:

git clone https://github.com/django/django.git

 

3. Name a few databases supported by Django.

Ans:- MySQLSQLite 3PostgreSQL, Oracle, and NoSQL databases like MongoDB and GoogleAppEngine Datastore.
 

4. How can we change the default port in Django?

Ans:- By default, the runserver command starts the development server on the internal IP at port 8000. To change the server's port, pass the following command:

python manage.py runserver 3000

 

Here the server port will start at port 3000.

Key Takeaways

This blog covered the Django Installation process in depth and the other aspects like python installation, databases, and the web server. We also saw how to launch a basic Django application.

Don't stop here. Check out the blogs Best Django BooksTop 30 Basic Django Interview Questions: Part 1, and Top 30 Intermediate Django Interview Questions: Part 2.

We hope you found this blog useful. Liked the blog? Then feel free to upvote and share it.

Live masterclass