Have you been itching to get your hands on the latest versions of Django, but haven’t found an easy way to do it on Fedora? You aren’t alone! We know that there are tons of new users who are interested in technology like Django, and we want to help them get set up quickly with the software they need.

Advertisement

This blog post will walk you through how to get started with your local testing environment for Django on Fedora.

Prerequisites:Basic knowledge of using a Linux terminal/command line and installation of software packages.
Objective:To setup the development environment for Django on Fedora

Step 1 – Installing Python

First, let’s make sure you have the latest versions of Python and Django installed. Open a terminal window, and start by updating your system:

sudo apt update && apt upgrade 

Fedora’s latest versions have already installed Python 3. The minimal installation systems may not have Python installed, Execute the below commands to install it. Also, install pip on your system.

sudo dnf install python3 python3-pip 

Once the installation is finished successfully, you can find the Python version with the python3 -V command.

Step 2 – Install Django on Fedora

Django source code is available as a Github repository. This tutorial uses pip3 for the Django installation on Fedora Linux. Simply execute the following command from the terminal:

pip3 install Django 

You will get a django-admin command, that is used to initialize new Django applications. To find the version of the django-admin command, type:

django-admin --version 

2.2.5

Step 3 – Create a New Django Application

Django has been installed on your system. Now we will create a new Django application. The django-admin command allows you to create a new Django application via the 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 Debian Linux.

cd /var/www 
django-admin startproject django_app 

This will create a django_app directory. Switch to that directory and run the migrations for the first time:

cd django_app 
python3 manage.py migrate 

Step 4 – Create Super Admin Account

Django provides a super admin panel for administering it. You need to create a super user account for the first time. Run the following command from your Django application to create an account.

python3 manage.py createsuperuser 

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 enable external hosts, edit the settings.py file and add IP under ALLOWED_HOSTS.

nano django_app/settings.py 

Add IP:

ALLOWED_HOSTS = ['192.168.1.239']

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.

python3 manage.py runserver 0.0.0.0:8000 

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.

http://192.168.1.239:8000

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.

http://192.168.1.239:8000/admin

The Django admin dashboard looks like the below. Here you can add more users and groups to your application.

Conclusion

Django is one of the most popular frameworks for web development, and it’s easy to get started using it with Fedora. To get started, make sure you have the latest versions of Python and Django installed. Next, create a virtual environment for testing, and you can use the Live-reload Django app to make testing more efficient. Once you’re set-up, you can start building your next Django project. Now that you know how to get your own local testing environment set up, you can create your next Django project with ease.

Share.

1 Comment

Leave A Reply


Exit mobile version