email_address = "foo@bar.com" admin_uid = "foo" new_password = User.objects.make_random_password() # Create the user. new_user = User(username=admin_uid, email=email_address) new_user.set_password(new_password) new_user.is_active = True new_user.save() # Add the user to the brand_specific_admin group g = Group.objects.get(name='brand_specific_admin') g.user_set.add(new_user)