diff --git a/home/management/commands/save_user.py b/home/management/commands/save_user.py new file mode 100644 index 000000000..658424e6e --- /dev/null +++ b/home/management/commands/save_user.py @@ -0,0 +1,11 @@ +from django.core.management.base import BaseCommand +from django.utils.translation import gettext_lazy as _ + +from iogt_users.models import User + + +class Command(BaseCommand): + def handle(self, *args, **options): + User.objects.filter(first_name=None).update(first_name='') + User.objects.filter(last_name=None).update(last_name='') + self.stdout.write(_('Users have been saved successfully!')) diff --git a/iogt_content_migration/management/commands/load_v1_users.py b/iogt_content_migration/management/commands/load_v1_users.py index cbb656f76..8f6801bfe 100644 --- a/iogt_content_migration/management/commands/load_v1_users.py +++ b/iogt_content_migration/management/commands/load_v1_users.py @@ -225,8 +225,8 @@ def migrate_user_accounts(self): 'last_login': row['last_login'], 'is_superuser': row['is_superuser'], 'username': row['username'], - 'first_name': row['first_name'], - 'last_name': row['last_name'], + 'first_name': row['first_name'] or '', + 'last_name': row['last_name'] or '', 'email': row['email'], 'is_staff': row['is_staff'], 'is_active': row['is_active'],