What is Django?
Python is a popular programming language. Django is a free toolkit, called a framework, for building websites in Python. A framework gives you ready-made parts, like a kit of building blocks. With Django you can build blogs, shops, news sites and apps with logins.
Why normal hosting is not always enough
A simple site made of HTML files can be copied to any hosting. A Django site is a running program. The server must start Python, keep the program alive and pass visitors to it. So the hosting must support Python apps.
What Django hosting needs
- Python: a version your Django release supports.
- A way to run the app: a tool such as Gunicorn, uWSGI or Passenger that connects the web server to your Python code.
- A database: Django works with MySQL, PostgreSQL and SQLite. SQLite is a simple database kept in one file.
- A virtual environment: a private folder holding only the packages your project needs. It keeps projects apart.
- Static files: pictures, styles and scripts that need their own folder and setup.
- SSL: a digital lock for https.
Types of hosting for Django
- Shared hosting with a Python app tool. Some control panels let you set up a Python app with a few clicks.
- VPS. A virtual private server is your own slice of a computer. You get full control, but you set everything up yourself. This needs root access.
- Dedicated server. A whole server, for large projects.
Ask Hostvento support which of these your plan supports for Python and Django.
Basic idea of a deployment
- Upload your project to the server.
- Make a virtual environment and install packages from
requirements.txt. - Set the database details in
settings.py. - Run the database setup with
python manage.py migrate. - Collect static files with
python manage.py collectstatic. - Point the app server and the web server to your project.
- Set
DEBUG = Falseand list your domain inALLOWED_HOSTS.
Warning: Never leave DEBUG = True on a live site. It can show private details. Back up your database before running migrations.
Quick recap
- Django is a Python framework for building sites.
- Django hosting must run Python apps, not just static files.
- You need an app server, a database and a virtual environment.
- Shared hosting may work if Python apps are supported. Otherwise use a VPS.
- Turn off debug mode on a live site.