Skip to content

Instantly share code, notes, and snippets.

@labibmuhajir
Created August 23, 2024 02:54
Show Gist options
  • Save labibmuhajir/a8d7f455c4438770355dd6080b0f2009 to your computer and use it in GitHub Desktop.
Save labibmuhajir/a8d7f455c4438770355dd6080b0f2009 to your computer and use it in GitHub Desktop.
Create super user in cpanel
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