Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import sys
- # First, add the project to PATH. Adjust as needed.
- PWD = os.path.dirname(os.path.abspath(__file__))
- PROJECT_PATH = os.path.abspath(os.path.join(PWD, '../../../../'))
- sys.path.append(PROJECT_PATH)
- # Second, configure this script to use Django
- import django
- os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')
- try:
- django.setup()
- except AttributeError:
- print django.VERSION
- from django.contrib.auth.management.commands import changepassword
- from django.core import management
- # Create the super user and sets his password.
- management.call_command('createsuperuser', interactive=False, username="admin", email="dummy@example.com")
- command = changepassword.Command()
- command._get_pass = lambda *args: 'password'
- command.execute("admin")
Add Comment
Please, Sign In to add comment