Create script

This script creates profiles for all those users who do not have one.
This commit is contained in:
Kristofers Solo 2023-06-30 03:10:23 +00:00
parent abd777b6dd
commit 8aad1a53ee

View File

@ -0,0 +1,13 @@
from account.models import Profile, User
from django.core.management.base import BaseCommand
class Command(BaseCommand):
help = "Creates profiles for all users who do not have one."
def handle(self, *args, **options):
users_without_profile = User.objects.filter(profile=None)
for user in users_without_profile:
Profile.objects.create(user=user)
self.stdout.write(self.style.SUCCESS(f"Profile created for {user.username}"))