def handle(self, *args, **options): for one_user in User.objects.all(): if not one_user.is_staff and one_user.is_active: Key1 = generate_key() Key2 = generate_key() PrivateKey = generate_key_from(Key1, one_user.email) new_obj = ApiKeys(public_key = Key2, private_key = PrivateKey, user = one_user) new_obj.save()
def new_api_key(one_user): Key1 = generate_key() Key2 = generate_key() PrivateKey = generate_key_from(Key1, one_user.email) new_obj = ApiKeys(public_key=Key2, private_key=PrivateKey, user=one_user) new_obj.save()