How to install Django on CentOS 8?

Windows Articles

Error in Windows 10 preventing them from using the internet

The Windows 10 May 2020 Update brought more problems than solutions. Users around the world are complaining about a new bug. A...

How to install MyWebSQL on Ubuntu 20.04?

Managing a database server with MySQL is not an easy task. Therefore, specialized tools are required to improve the task. In Osradar...

New Office app arrives: free and renewed

Microsoft goes one step further. This time positive. This week the Redmond people launched the new Office app for Windows 10. The...

How to install Gradle on Ubuntu 20.04?

Hi, folks. In this post dedicated to Java, you will learn how to install Gradle on Ubuntu 20.04 Gradle...

Linux 5.8 Released

A few days ago, Luis Torvalds was discussing to release Linux 5.8-rc8 or he releases Linux 5.8 as stable. In the end,...
angeloma
angeloma
Senior Writer and partner

Developing web applications is usually related to PHP frameworks. However, Python, which is a very versatile programming language, also has a framework that allows you to do it. And in fact, it is quite efficient. So, if you like Python and you think it is convenient to develop web applications with this language, then you should know Django. In this post, you will learn how to install Django on CentOS 8.

Briefly, What is Django?

The Django is a framework written in python to develop web applications. It respects the design pattern Model – View -Template and focuses on making applications quickly and under the focus of DRY (Don’t repeat yourself).

It is incredibly popular and great websites are created with this Framework. So, let’s go for it.

Install Django on CentOS 8

1.- Install Python and Pip on CentOS 8

Django is a framework built-in Python. That’s why you have to have it in your system. However, don’t worry that most Linux distributions are installed by default.

Different from python, Pip is not installed by default. And it is another necessary package for Django. So, we have to install it.

Open a terminal session and run the following:

:~$ su
:~# dnf install python36 python3-pip
1.- Install Python pip on CentOS 8
1.- Install Python pip on CentOS 8

Now check the installed version of Pip with the following command:

:~# pip3 -V
pip 9.0.3 from /usr/lib/python3.6/site-packages (python 3.6)

With this, Python and Pip are ready to continue the work.

Install Django on CentOS 8

Now we proceed to install Django with the following command.

:~# pip3 install Django
2.- Install Django on CentOS 8
2.- Install Django on CentOS 8

Then, check the version that has been installed:

:~# django-admin --version
3.0.2

Remember that the version will change according to when you do this tutorial.

The next step is to start a new Django project. Just use the following command:

:~# django-admin startproject example

Replace example with the name you wish to give the project.

Then navigate to the created folder, in this case, example, and make the migrations.

:~# cd example
:~# python3 manage.py migrate
3.- Installing Django on CentOS 8
3.- Installing Django on CentOS 8

Now you need to create the Django console administrator user. We achieve this with the following command:

:~# python3 manage.py createsuperuser
4.- Creating the user for Django
4.- Creating the user for Django

As you see in the picture, we will be asked for a username. Then, we define a password.

When you finish creating the user, you have to change a value in the Django configuration. To do so, open the settings file with the following command:

:~# nano example/settings.py

And modify the following parameter:

ALLOWED_HOSTS = ['COMPUTER_IP_WHICH_IS_RUNNING_DJANGO']
5.- Configuring Django on CentOS 8
5.- Configuring Django on CentOS 8

Then save the changes and close the editor.

Django applications are served through the 8000 port. Therefore, it’s necessary to open this port in the firewall so that we can access it.

:~#firewall-cmd --add-port=8000/tcp --zone=public --permanent
 success
:~# firewall-cmd --reload
 success

Now open your web browser and go to http://localhost:8000 or http://pc-ip:8000 and you will see this:

7.- Django running on CentOS 8
7.- Django running on CentOS 8

If you want to access the administration panel, add to the previous address /admin.

8.- Django log in page
8.- Django log in page

Just type your credentials and you will see the dashboard.

9.- Django dashboard
9.- Django dashboard

So, Django is installed and ready to work.

Conclusion

Django is a powerful framework. It combines the simplicity of python with the power of a whole team willing to improve the framework. Besides this, the installation on CentOS 8 is not complicated at all.

Please share this post and join our Telegram Channel.

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

Error in Windows 10 preventing them from using the internet

The Windows 10 May 2020 Update brought more problems than solutions. Users around the world are complaining about a new bug. A...

How to install MyWebSQL on Ubuntu 20.04?

Managing a database server with MySQL is not an easy task. Therefore, specialized tools are required to improve the task. In Osradar...

New Office app arrives: free and renewed

Microsoft goes one step further. This time positive. This week the Redmond people launched the new Office app for Windows 10. The...

How to install Gradle on Ubuntu 20.04?

Hi, folks. In this post dedicated to Java, you will learn how to install Gradle on Ubuntu 20.04 Gradle...

Linux 5.8 Released

A few days ago, Luis Torvalds was discussing to release Linux 5.8-rc8 or he releases Linux 5.8 as stable. In the end,...