FedoraRHEL Based

How To Install Django on Fedora 38

Install Django on Fedora 38

In this tutorial, we will show you how to install Django on Fedora 38. For those of you who didn’t know, Django is a powerful and popular Python-based web framework that simplifies the process of building robust web applications.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of Django on a Fedora 38.

Prerequisites

  • A server running one of the following operating systems: Fedora 38.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for Django.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Django on Fedora 38

Step 1. Before we can install Django on Fedora 38, it’s important to ensure that our system is up-to-date with the latest packages. This will ensure that we have access to the latest features and bug fixes and that we can install Django without any issues:

sudo dnf upgrade --refresh

Step 2. Installing Python and Pip.

Python is a prerequisite for running Django. Confirm whether Python is already installed on your system by entering the following command:

python3 --version

If Python is not installed, use the package manager to install it:

sudo dnf install python3 python3-pip

To avoid conflicts with other Python projects, it is best practice to create a virtual environment dedicated to your Django project.  Virtualenv is a tool that creates isolated Python environments. Install it by running the following command:

pip3 install virtualenv

Let’s create a directory for your Django project and navigate to it using the terminal. Execute the following commands:

mkdir my_django_project
cd my_django_project

Now, create a virtual environment by running the following command:

virtualenv myenv

To activate the virtual environment, execute the appropriate command based on your shell:

source myenv/bin/activate

Step 3. Installing Django on Fedora 38.

By default, Django is not available on Fedora 38 base repository. Django is available on the Python Package Index (PyPI) and can be installed with a simple Pip command:

pip install django

To ensure Django has been installed successfully, run the following command:

django-admin --version

Step 4. Setting Up a Django Project.

With Django installed, it’s time to create a new Django project. In your terminal, enter the following command to create a new Django project:

django-admin startproject myproject

This command will create a directory named “myproject” with the basic project structure and files.

Let’s take a moment to understand the structure of a Django project. Inside the “myproject” directory, you’ll find the following files and directories:

  • manage.py: A command-line utility for various Django project operations.
  • myproject/: The project’s Python package contains settings, URLs, and other configurations.
  • myproject/settings.py: Configuration settings for your Django project.
  • myproject/urls.py: Defines the project’s URL patterns.
  • myproject/wsgi.py: A WSGI-compatible entry point to your project.

To test your Django installation and ensure everything is functioning correctly, let’s start the development server. Navigate to your project’s root directory using the terminal and enter the following command:

python manage.py runserver

Step 5. Configure Firewall.

In order to allow access to port 8000, you need to modify firewall rules in a new SSH connection:

firewall-cmd --add-port=8000/tcp --zone=public --permanent
firewall-cmd --reload

Step 6. Accessing Django Web Interface.

Once successfully installed, open your favorite browser and navigate tohttp://192.168.77.20:8000. You should see the following page:

Install Django on Fedora 38

To access the Admin dashboard, you can use the following URL: http://192.168.77.20:8000/admin/

Install Django on Fedora 38

Congratulations! You have successfully installed Django. Thanks for using this tutorial for installing Django on your Fedora 38 system. For additional help or useful information, we recommend you check the official Django website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button