Django: How to Install and Run Your First Web App

Installation & Setup

What is Django?

The official Django website describes itself as “the Web framework for perfectionists with deadlines.” It’s an open-source web framework that follows the model-view-template architectural pattern.

Simple Web App Architecture

Setting Up

To get started, we will have to install some software on our computer. I’ll be walking you through installation for the following tools:

  • Python
  • Pip
  • Django

Python

Everything in Django is built using the Python programming language, so we’ll definitely need to have that installed. There are two major “flavors” of Python out there: Python 2 and Python 3. Unless you have a specific reason to go with Python 2, I would recommend using Python 3 from the get-go.

Pip

Pip is a package manager for Python. It’s what we’ll use to install Django and its many dependencies. Luckily, you probably already have it installed. Try it out by saying pip --version. If a version prints out with a link to your Python version, you’re good to go. It should look like this:

pip 19.1.1 from /path/to/binary/pip (python 3.5)
python -m pip install pip

Django

At last! We can finally install Django.

pip install django
django-admin --version
2.2.2

Generating the Project

With Django, we don’t have to start from scratch. The basic format of the project will be generated for us by the django-admin tool.

django-admin startproject hello_django
cd hello_django
du -a
0 ./hello_django/__init__.py
4 ./hello_django/settings.py
4 ./hello_django/urls.py
0 ./hello_django/wsgi.py
8 ./hello_django
4 ./manage.py
12 .
python manage.py runserver
...
Django version 2.2.2, using settings 'hello_django.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store