Exemplo n.º 1
0
    def handle(self, *args, **options):
        
        first = input("Enter your first name: ") 
        last = input("Enter your last name: ")
        new_email = input("Enter your email address: ")
        odin = input("Enter your ODIN username: ")

        try:
            new_user = User(first_name = first, last_name = last, email = new_email, username = odin, is_active=True, is_staff=True)
            new_user.save()
            
        except Exception as e:
            self.stdout.write('Unable to add user!')

        self.stdout.write('Successfully added admin user!')
Exemplo n.º 2
0
Arquivo: forms.py Projeto: kfarr2/ITS
def create_user(new_first_name, new_last_name, new_email):

    """
    Generates a unique user name.
    """

    new_username = '******' + new_first_name + new_last_name
    i = 0

    while User.objects.filter(username=new_username + str(i)).exists():
        i += 1

    new_username = new_username + str(i)
    new_user = User(first_name=new_first_name, last_name=new_last_name,
                    email=new_email, username=new_username, is_active=False, is_staff=False)

    new_user.save()

    return new_user