Guest User

Untitled

a guest
Jan 30th, 2018
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. import os
  2. import sys
  3.  
  4. # First, add the project to PATH. Adjust as needed.
  5. PWD = os.path.dirname(os.path.abspath(__file__))
  6. PROJECT_PATH = os.path.abspath(os.path.join(PWD, '../../../../'))
  7. sys.path.append(PROJECT_PATH)
  8.  
  9. # Second, configure this script to use Django
  10. import django
  11. os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')
  12.  
  13. try:
  14. django.setup()
  15. except AttributeError:
  16. print django.VERSION
  17.  
  18. from django.contrib.auth.management.commands import changepassword
  19. from django.core import management
  20.  
  21. # Create the super user and sets his password.
  22. management.call_command('createsuperuser', interactive=False, username="admin", email="dummy@example.com")
  23. command = changepassword.Command()
  24. command._get_pass = lambda *args: 'password'
  25. command.execute("admin")
Add Comment
Please, Sign In to add comment