mirror of
https://github.com/kristoferssolo/FOSSDB.git
synced 2026-03-22 00:26:22 +00:00
Create script
This script creates profiles for all those users who do not have one.
This commit is contained in:
13
src/apps/account/management/commands/create_profiles.py
Normal file
13
src/apps/account/management/commands/create_profiles.py
Normal 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}"))
|
||||||
Reference in New Issue
Block a user