Python

How to create superuser in django project hosted in cPanel without terminal

How to create superuser in django project hosted in cPanel without terminal , someone asked me to explain?

In this tutorial I will show you how to create superuser in django project hosted in cPanel without terminal & SSH feature.

Create a file CreateSuperUser.py and paste the below code on it.

CreateSuperUser.py:

import subprocess

try:
    subprocess.check_call(
        'echo "from django.contrib.auth.models import User; '
        'User.objects.create_superuser(\'admin\', \'admin@example.com\', \'password\')" | '
        'python manage.py shell',
        shell=True
    )
    print("Superuser created successfully")
except subprocess.CalledProcessError as e:
    print(f"Error creating superuser: {e}")


Copy the file location and paste in the textbox and execute the script.
Execute python Script

Video Guide:[Create SuperUser in django project without terminal & SSH Access]

Post your comments / questions