Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

How to install the Django framework

This guide shows you how to install Django and start a first project on a Linux server. A VPS or dedicated server works best because you control the software.

How-To Guides2 min read10 steps

What is Django?

Django is a free toolkit for building websites with Python. Python is a popular programming language. A framework is like a box of ready-made parts. You build your site faster because you do not start from zero.

Before you start

  • You need SSH access to your server. SSH lets you type commands on a remote computer.
  • You need Python 3 installed. Check with python3 --version.

Steps

  1. Log in to your server over SSH.
  2. Install pip and the virtual environment tool. On Ubuntu or Debian use this command.
sudo apt update
sudo apt install -y python3-pip python3-venv

On CentOS or RHEL use sudo yum install -y python3-pip instead. Pip is the tool that downloads Python add-ons.

  1. Make a folder for your project and go into it.
mkdir mysite
cd mysite
  1. Create a virtual environment. This is a private box for your project's add-ons. It keeps them apart from the rest of the server.
python3 -m venv venv
  1. Switch it on.
source venv/bin/activate

Your prompt now starts with (venv).

  1. Install Django.
pip install django
  1. Check the version.
python -m django --version
  1. Start a new project. The dot at the end puts the files in the current folder.
django-admin startproject config .
  1. Create the starting database tables.
python manage.py migrate
  1. Start the test server.
python manage.py runserver 0.0.0.0:8000

Open http://YOUR-SERVER-IP:8000 in your browser. You should see the Django welcome page. If the page does not load, your firewall may block port 8000.

If the browser says "DisallowedHost", open config/settings.py. Add your server address to the ALLOWED_HOSTS list.

Tip: The runserver command is only for testing. For a live site, use a proper setup such as Gunicorn behind a web server. Ask Hostvento support if you are not sure how your plan handles Python apps.

Quick recap

  • Install Python 3, pip and venv.
  • Create and activate a virtual environment.
  • Install Django with pip install django.
  • Start a project and run migrate.
  • Use runserver for testing only.