Quickly Install Django Web App Framework on Debian 12

In this guide, you will learn to Install the Django Web App Framework on Debian 12 From Terminal and Access the Admin Web Interface. Django is a high-level Python web framework. It enables developers to build web applications quickly, efficiently, and securely. Django offers amazing features including:

  • Object-Relational Mapping (ORM)
  • URL Routing
  • Template Engine
  • Form Handling
  • Authentication and Authorization
  • Admin Interface
  • Security Features
  • Internationalization and Localization
  • Middleware
  • Scalability and Performance

Now follow the steps below to start your Django installation on Debian 12.

Step-by-Step Guide To Install Django Web App Framework on Debian 12

Before you start your Django setup on Debian 12, you must access your server as a non-root user with sudo privileges. To do this, you can check this guide on Initial Server Setup with Debian 12.

Also, you must install the latest Python and Pip on your server. To do this, you can check this guide on Installing Python 3.12 on Debian Server.

Then, follow the steps below to complete this guide.

Step 1 – Use Python Pip to Install Django on Debian 12

First, verify your Python and Pip installation by checking their version:

python3 --version
Output
Python 3.12.2
pip3 --version
Output
pip 24.0 from /usr/local/lib/python3.12/site-packages/pip (python 3.12)

Then, you can simply use Pip to get your Django web app framework. You can install it in the user space or globally.

To install Django in the user space, run the following command:

sudo pip3 install --user Django

To install Django globally, you can run the command below:

sudo pip3 install Django

Once your installation is completed, you will get the following output:

Output
Successfully installed Django-5.0.3 asgiref-3.7.2 sqlparse-0.4.4

Step 2 – Verify Django Admin Tool on Debian 12

The installation of Django on Debian 12 will provide you with the django-admin tool to manage the projects. You can check it by using the command below:

which django-admin
Output
/usr/local/bin/django-admin

Also, you can check your django-admin installation by checking its version:

django-admin --version
Output
5.0.3

Step 3 – Create a Test App with Django

At this point, we want to create a test app with Django to check if it is working correctly. First, create a project directory and switch to it with the commands below:

# mkdir project 
# cd project 

Then, use the django-admin tool to start a project named test_app, you can choose your desired name:

django-admin startproject test_app

Switch to your Django web app project directory on Debian 12:

cd test_app

Now you can use Python 3 to apply pending migrations:

python3 manage.py migrate

In your output you will see:

use Python 3 to apply pending migrations for Django App

Step 4 – Set up Django Super User on Debian 12

At this point, you must create an admin user for your Django project. From your test app directory, run the command below:

python3 manage.py createsuperuser

Provide a name, email address, and password for your super user:

Set up Django Super User on Debian 12

Step 5 – Configure Django Web App Framework

At this point, you must allow external access to the Django app on Debian 12. To do this, you must open your test app settings file from the project directory with your favorite text editor like Vi Editor or Nano Editor:

sudo vi test_app/settings.py

At the file, look for the ALLOWED_HOSTS line and set it to your host IP.

ALLOWED_HOSTS = ['host-ip']

When you are done, save and close the file.

Step 6 – Start the Django Web App Project

Now you can start your Django project on Debian 12 with the command below:

python3 manage.py runserver 0.0.0.0:8080

In your output you will see:

Start the Django Web App Project

Step 7 – Access Django Admin Interface

At this point, you can access your Django admin interface by typing your host IP in your web browser followed by 8080/admin:

http://host-ip:8080/admin

You will see your Django web admin login screen on Debian 12. Enter your superuser and password you have created before and click Log in.

Django admin web login screen Debian 12

You will see your Django Admin interface on Debian 12.

Django Admin interface on Debian 12

Django admin UI provides a user-friendly and feature-rich interface for managing application data and performing administrative tasks efficiently.

Also, you can finish your task by pressing CTRL+C from your terminal.

For more information, you can check the official docs page.

Conclusion

At this point, you have learned to install the Django web app framework on Debian 12, configure your Django web app, and access the admin interface. You can easily manage your app data by using the Django. Hope you enjoy it.

Also, you may like to read the following articles:

Fix Error Module Not Found named ‘distutils’

Install Zenmap on the Debian 12 Linux Terminal

Fail2ban Installation on Debian 12 Bookworm

Install Ruby on Rails on Debian 12 Bookworm

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!