In this guide, we will take you through the steps to Install Django on Fedora 35/34/33/32/31/30. Django is a free and open source high-level Python Web framework built by experienced developers to encourage rapid development and pragmatic design. Django takes care of much of the hassle of Web development, so you can focus on writing your app without needing to reinvent the wheel.
There are two methods that you can use to install Django on Fedora 35/34/33/32/31/30.
- Install Django on Fedora with pip|pip3
- Install Django on Fedora by building from Git
Let’s look at how to use either of the methods to Install Django on Fedora 31/30/29.
Step 1: Install Python3 and Pip3
Your Fedora system should come with Python 3, if it doesn’t have it, install by running the commands below on your terminal.
sudo dnf -y install vim python3 python3-pip
Step 2: Install Django on Fedora 35/34/33/32/31/30 with pip3
The easiest and quickest method of installing Django on Fedora 31/30/29 is with pip3.
Check your Python version
$ python3 -V
Python 3.7.0
$ python3 -V
Python 3.10.0
Ensure pip3 is installed
$ sudo dnf -y install python3-pip
$ pip3 -V
pip 21.2.3 from /usr/lib/python3.10/site-packages/pip (python 3.10)
Once installed, Download and install Django on Fedora 31/30/29 with it.
pip3 install --user Django
Installation output:
Collecting Django
Downloading Django-3.2.9-py3-none-any.whl (7.9 MB)
|████████████████████████████████| 7.9 MB 9.8 MB/s
Collecting sqlparse>=0.2.2
Downloading sqlparse-0.4.2-py3-none-any.whl (42 kB)
|████████████████████████████████| 42 kB 2.4 MB/s
Requirement already satisfied: pytz in /usr/lib/python3.10/site-packages (from Django) (2021.1)
Collecting asgiref<4,>=3.3.2
Downloading asgiref-3.4.1-py3-none-any.whl (25 kB)
Installing collected packages: sqlparse, asgiref, Django
Successfully installed Django-3.2.9 asgiref-3.4.1 sqlparse-0.4.2
The installation of Django will give you django-admin
command to manage Projects,
$ which django-admin
~/.local/bin/django-admin
Check django-admin
version using:
$ django-admin --version
3.2.9
Install Django on Fedora35/34/33/32/31/30 from Git source code
You can also install Django from source code. Make sure you have Git installed:
sudo dnf -y install git
Check out Django’s main development branch like so:
git clone https://github.com/django/django.git
This will create a directory django in your current directory. Next is to make Django’s code importable and django-admin
utility command available:
pip3 install -e django/
Step 3: Create a test Django Application
Create a Django test application by running
mkdir projects
cd projects
django-admin startproject test_app
cd test_app
test_app
is the name of our Django Project.
Apply pending migrations
$ python3 manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying admin.0003_logentry_add_action_flag_choices... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying auth.0008_alter_user_username_max_length... OK
Applying auth.0009_alter_user_last_name_max_length... OK
Applying sessions.0001_initial... OK
Step 4: Create an Admin Account
Create a Django project superuser account by running the following commands from your Django application directory.
$ python3 manage.py createsuperuser
Username (leave blank to use 'jmutai'): admin
Email address: [email protected]
Password: <INPUT-PASSWORD>
Password (again): <RE-ENTER-PASSWORD>
Superuser created successfully.
Input your admin username, email address, and password.
Step 5: Allow external access to the Django web application (Optional)
Note that by default Django doesn’t allow external access to the application, you need to explicitly define an ACL.
vim test_app/settings.py
Edit the lineALLOWED_HOSTS
to whitelist your Computer IP or LAN subnet.
ALLOWED_HOSTS = ['192.168.18.23']
You can now start Django application server:
$ python3 manage.py runserver 0.0.0.0:8090
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
November 04, 2021 - 21:40:16
Django version 3.2.9, using settings 'test_app.settings'
Starting development server at http://0.0.0.0:8090/
Quit the server with CONTROL-C.
If you open the URL http://[server IP/hostname]:8090
you should see a successful message like below:
Django Administration page is available on :8090/admin
Login with created username and password:
The admin page allows you to add other users, add groups, change password e.t.c. It looks like below:
Enjoy writing your Web application with Django Framework on Fedora 35/34/33/32/31/30. Don’t forget to check other Fedora articles available on our website.