How to Deploy a Python Django Application on cPanel

Deploying a Django application on cPanel can seem challenging at first, but with the right steps, it becomes manageable. cPanel supports Python applications through its Setup Python App feature, which allows you to run Django projects efficiently. Below is a step-by-step guide to deploying your Django app on cPanel.
Step 1: Log in to cPanel

Step 2: Create a Python Application
- In cPanel, locate the Setup Python App feature (under the Software section)

Setup Python -1 - Click on Create Application.

Setup Python -2 - Choose the Python version required for your Django project (e.g., Python 3.9 or above).

Setup Python -3 - Specify the application root directory (e.g., pytest), which will house your Django project.

Setup Python -4 - Specify the application URL (e.g., https://mydomain.com or a subdomain).

Setup Python -5 - Click Create to set up the Python application.(Leave the Application Startup file and Application entry point blank, the system will automatically setup)

Setup Python -6 
Setup Python -7 7. Click on the Open button by the Application URL or visit the domain used to verify the application is active.

Setup Python -8
Step 3: Setup Django
- Copy the command by clicking on the command in the python application page.

2. Open terminal on the cPanel dashboard, paste the command and hit enter.(If terminal is not enabled, contact support)

3. Print the current directory by running the command “pwd” afterwards install Django by running the “pip install django“.

3. Create the django project folder by running: “django-admin startproject projectname .”.(Note: change the projectname to your preferred project name)

4. On the python application page, update the Application startup file to the wsgi.py in the django directory, that is : “projectname/wsgi.py“.

5. In the File Manager, open the application directory. Open the Django(projectname) directory and locate the settings.py file.


6. In the settings.py file, search for “ALLOWED HOST=[]“. In between the parenthesis, type in the domain or subdomain name the application will be hosted.
(Example: ALLOWED HOST=[‘pytest.shostguide.com’])

7. Restart the python application.

8. The Django application is live.


