Step 1 – Prerequsities
The latest versions of operating systems come with default Python 3 installed. The minimal installation systems may not have Python installed, Execute the below commands to install it. Also, install pip on your system. Then check the Python and pip version:
Step 2 – Install Django on Debian
Django source code is available as a Github repository. You can also use pip to install Django on Debian 9 systems. In this tutorial, I use pip3 for the Django installation on Ubuntu. Run the below command from Linux terminal: You will get a django-admin command for creating new projects. Check the current installed verson:
Step 3 – Create Django Application
The django-admin command provides you the option to create a new Django application via command line. First, navigate to the directory you need to create a new application. Then use the django-admin startproject command followed by the application name to create a new Django application on a Debian Linux. After that migrate the pending changes.
Step 4 – Create Super Admin Account
Also, create a superuser account for the administration of the Django application. Run the following command from your Django application directory.
Make sure all the migrations completed successfully. Once done, go to the next step.
Step 5 – Run Django Application
Your Django application is ready to use. By default, Django doesn’t allow external hosts to access the web interface. To allow external hosts, edit settings.py file and add IP under ALLOWED_HOSTS. Add IP: Here 192.168.1.239 is the IP address of the system where Django is installed. Finally, run the Django application server with the below command. Here 0.0.0.0:8000 defined that Django will listen on all interfaces on port 8000. You can change this port with any of your choices.
The Django application server is running now. Open your favorite web browser and access to Django system IP on port 8000. This will show you the default Django web page.
Django also provides an administrative web interface. You can access this at /admin subdirectory URL of your Django application. Use superuser login credentials created in the previous step.
The Django admin dashboard looks like below. Here you can add more users and groups for your application.