mirror of
https://github.com/kristoferssolo/FOSSDB.git
synced 2025-10-21 17:50:35 +00:00
Create script
This script creates profiles for all those users who do not have one.
This commit is contained in:
parent
abd777b6dd
commit
8aad1a53ee
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}"))
|
||||||
Loading…
Reference in New Issue
Block a user