This blog post will walk you through how to get started with your local testing 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: 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. 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: 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:
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. This will create a django_app directory. Switch to that directory and run the migrations for the first time:
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.
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. Add IP: 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.
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.
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.
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.