In this article, we will have explained the necessary steps to install and configure Django on Debian 10. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.
Django is the most popular web framework which is designed to develop fully-featured Python Web Applications. By using Django you can build secure, scalable and maintainable dynamic web applications.
Install Django on Debian
Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.
sudo apt update sudo apt upgrade
Step 2. Install Python virtual environment.
The Django is a framework written in python to develop web applications. Now install python using following command:
sudo apt install python3 python3-pip
You can verify that Python 3 is installed on your system by typing:
$ pip3 -V pip 19.1 from /usr/lib/python3/dist-packages/pip (python 3.7)
Step 3. Install Django on Debian 10.
Install Django using the Python package manager pip:
sudo pip3 install Django
Verify the installation using the following command which will print the Django version:
$ django-admin --version 2.2.6
Step 4. Create a new Django project.
Now, I will create a new project called linuxtips:
cd /var/www/ sudo django-admin startproject linuxtips
Next, navigate into the linuxtips folder and migrate to set the initial configuration:
cd linuxtips sudo python3 manage.py migrate
Then, you have to create the superuser to manage the project:
sudo python3 manage.py createsuperuser
The next step is to edit the project configuration file to make it accessible from any computer:
nano example/settings.p
And edit the following entry:
ALLOWED_HOSTS = ['YOUR_COMPUTER_IP_WHICH_IS_RUNNING_DJANGO']
Next, serve the project:
sudo python3 manage.py runserver 0.0.0.0:8000
Step 5. Accessing Django.
Open http://127.0.0.1:8000 in your web browser and you will be presented with the default Django landing page:
Congratulation, you have learned how to install and configure Django on Debian 10 Buster. If you have any question, please leave a comment below.