Created
August 23, 2024 02:54
-
-
Save labibmuhajir/a8d7f455c4438770355dd6080b0f2009 to your computer and use it in GitHub Desktop.
Create super user in cpanel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "projectdir.settings") | |
import django | |
django.setup() | |
from django.contrib.auth.models import User | |
def create_superuser(username, password, email): | |
if not User.objects.filter(username=username).exists(): | |
User.objects.create_superuser(username=username, password=password, email=email) | |
print(f'Superuser {username} created.') | |
else: | |
print(f'Superuser {username} already exists.') | |
# Replace 'admin', 'password', '[email protected]' with your desired username, password, and email | |
create_superuser('user', 'password', 'email') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment