Step 1 – Install Python

CentOS 8 minimal installation systems do not have default Python installed. You can install Python 3 on your CentOS 8 via default repository. Just execute the following commands to install Python and PIP on your system. Then check the Python and pip version:

Step 2 – Install Django on CentOS 8

Django source code is available in the Github repository. But this tutorial uses pip3 for the Django installation on CentOS 8 and RHEL 8 Linux. Simply run the following command from the system terminal: You will get a django-admin command for creating new projects. Check the current installed verson:

Step 3 – Create Django Application

You have Django installed on your system. Let’s create a new 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 Admin User

Now, create a superuser account for the administration of the Django application. Run the following command from your Django application directory.

Step 5 – Run Django Application

A new 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.

Step 6 – Manage Firewalld

The system with an active firewall needs to open port to access Django over the network. Run the following commands to allow port 8000 for public users.

Step 7 – Access Django in Browser

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.

Conclusion

You have successfully installed Django and created a sample application on your CentOS 8 or RHEL 8 Linux system.

How To Install Django on CentOS RHEL 8   TecAdmin - 40How To Install Django on CentOS RHEL 8   TecAdmin - 56How To Install Django on CentOS RHEL 8   TecAdmin - 17How To Install Django on CentOS RHEL 8   TecAdmin - 46How To Install Django on CentOS RHEL 8   TecAdmin - 69How To Install Django on CentOS RHEL 8   TecAdmin - 96