Introduction
Django is a free and open-source web framework written in the python programming language. It follows the model-template-views architectural pattern and allows rapid development. Django is versatile in nature that can be used to create applications in multiple domains. It takes less time to develop a web application than other web frameworks.
This article will explain how to install and use Django on Fedora 35.
Prerequisites
- A root or non-root user with
sudo
privileges.
Install Python
Django is a Python-based web framework. Therefore, you'll need to install Python on your system before installing Django. Fedora 35 comes with Python 3 pre-installed, so you don't need to install it separately.
- Update the software repository.
$ sudo dnf update
- Confirm that Python is installed by running the following command.
$ python3 --version
Install PIP
- Pip is a package manager for Python that allows you to install and manage Python packages. To install Pip on your Fedora 35 system, run the following command.
$ sudo dnf -y install python3-pip
Install Django
- To install Django, run the following command.
$ sudo pip3 install Django
- Check which version of Django you have installed.
$ django-admin --version
- Run the following command to create the new project. This command creates a new directory called "project_name".
$ django-admin startproject project_name
- Run the below command to create an application for the project.
$ python3 project_name/manage.py startapp app_name
- Migrate the project database.
$
python3 project_name/manage.py migrate
- Open
setting.py
file using the below command.
locate the$ sudo vi project_name/project_name/settings.py
ALLOWED_HOSTS
inside the file and list your serve IP addresses or domain names in the ALLOW_HOSTS then save and close the file. - Start the Django development server.
$ sudo python3 project_name/manage.py runserver your_server_ip:8000
Replace your IP address with <your_server_ip> in the above command.
Output: - Now, open your web browser and go to http://your_server_ip:8000/. If everything is installed correctly, you should see the default Django welcome page.