> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.elitehost.co.za/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# How can I deploy a Django application on cPanel without SSH/Terminal access?

Django is a high-level Python web framework designed to help developers build robust, scalable web applications quickly and efficiently. It offers a clean, pragmatic design, and comes with powerful features like an integrated admin interface, automatic database management, and built-in security measures against common web vulnerabilities.

Many well-known websites and companies use Django for their platforms, including Instagram, Spotify, Pinterest, Mozilla, and YouTube, showcasing Django’s ability to handle high-traffic, complex applications while maintaining performance and security.

Follow these steps to deploy Django on a cPanel account using the Setup Python App feature without needing SSH/Terminal access.

#### 1. Create a Python Application

1. **Navigate to cPanel** and click on **Setup Python App** under the Software section.
2. Click **Create Application**.
3. **Select Python Version**: Choose the Python version (e.g., 3.11).
4. **Application root**: Enter `django_app` (or any name you prefer for the root directory).
5. **Application URL**: Leave blank to host the app on the root domain, or enter a directory (e.g., django).
6. **Application startup file & Application entry point**: Leave these empty for now.
7. Click **Create** and wait for the app to be created.

#### 2. Create the Requirements File

1. Open **cPanel** → **File Manager** (For easier tab navigation, search for File Manager in cPanel, then right-click on File Manager and select “Open Link in New Tab.” This allows you to switch between tabs without losing your place)
2. Navigate to the **django_app** folder and create a new file named `requirements.txt`

#### 3. Add the Requirements File

1. Return to the **Setup Python App** tab.
2. In the **Configuration Files** section:
* In the **Add another file** field, type in `requirements.txt` and press enter.
3. Click **Edit** next to `requirements.txt` and enter the following: `Django`
4. Click **Save**.

#### 4. Install Requirements

1. Next to "Configuration Files", click **Run Pip Install** and select `requirements.txt`

#### 5. Create Django Project

1. In the **Execute Python Script** field, enter the following command, replacing `username` with your actual cPanel username, `3.11` with the Python version and `django_app` with your application root. Ensure you enter the . at the end, which specifies the project will be created in the current running directory.

```
/home/username/virtualenv/django_app/3.11/bin/django-admin startproject myapp .
```

This will create a `manage.py` script and a `myapp` folder in the **django_app** directory. You can verify this in the File Manager.

#### 6. Create a Static Folder

1. In the **File Manager**, create a folder named **static** inside the **public_html** directory.

#### 7. Edit Django Settings

1. In **File Manager**, open the file: **django_app/myapp/settings.py**
2. Edit the following line to match your domain name:

```
ALLOWED_HOSTS = ['exampledomain.co.za']
```

3. Add this line at the bottom, replacing `username` with your cPanel username:

```
STATIC_ROOT = '/home/username/public_html/static'
```

4. **Save** the changes.

#### 8. Configure Application Startup

1. Return to the **Setup Python App** tab.
2. In the **Application startup file** field enter `myapp/wsgi.py`

#### 9. Set Environment Variables

1. Under **Environment Variables**, click **Add Variable**:
* Name: `DJANGO_SUPERUSER_PASSWORD`
* Value: your desired admin password.
2. Click **Done**, 
3. Click **Save** at the top right.
4. Scroll up and **Restart**.

#### 10. Initialise Database and Create Superuser

To initialise your database, collect static files, and create an admin user, run these commands one by one in the **Execute Python Script** field:

```
manage.py migrate --noinput
manage.py collectstatic --noinput
manage.py createsuperuser --noinput --username admin --email admin@exampledomain.co.za
```

The Django installation should now be accessible at https://exampledomain.co.za and display "The install worked successfully! Congratulations!" with the admin interface at https://exampledomain.co.za/admin

If you have any questions or need further assistance, feel free to contact our [support team](https://my.elitehost.co.za/submitticket.php?step=2&deptid=14) or email helpdesk@elitehost.co.za.