33 lines
899 B
Python
33 lines
899 B
Python
from django.contrib.auth.models import User
|
|
from users.models import Profile,Agency
|
|
|
|
import random
|
|
import string
|
|
|
|
def randomStringwithDigitsAndSymbols(stringLength=10):
|
|
"""Generate a random string of letters, digits and special characters """
|
|
|
|
password_characters = string.ascii_letters + string.digits + string.punctuation
|
|
return ''.join(random.choice(password_characters) for i in range(stringLength))
|
|
|
|
username = "root"
|
|
password = randomStringwithDigitsAndSymbols(20)
|
|
print("USERNAME: " + username)
|
|
print("PASSWORD: " + password)
|
|
ag=Agency()
|
|
ag.save()
|
|
pr=Profile()
|
|
pr.agency=ag
|
|
try:
|
|
user=User.objects.create_user(username, 'support@digitale-agentur.com', password)
|
|
except:
|
|
send_mail
|
|
user = User.objects.get(username=username)
|
|
user.first_name = 'ROOT'
|
|
user.last_name = 'ROOT'
|
|
pr.user=user
|
|
pr.save()
|
|
user.profile = pr
|
|
user.is_superuser = True
|
|
user.is_stuff = True
|
|
user.save() |