Golden Codes - armanexplorer planet

Practical code snippets for Django, Python, Bash, Git and All!

View on GitHub

auto create superuser

Make it auto

superusers = User.objects.filter(is_superuser=True)
for superuser in superusers:
    print(superuser.email)

set new password

python manage.py changepassword <username>

or by code:

from django.contrib.auth.models import User

# Get the superuser
superuser = User.objects.get(username='admin')

# Set the new password
superuser.set_password('new_password')
superuser.save()