Compare commits
No commits in common. "14f9487919d6fa2d2264612a0f06bfb2d8d20489" and "7984ca1b77e6622ae5c344290efa436451799d81" have entirely different histories.
14f9487919
...
7984ca1b77
2 changed files with 3 additions and 7 deletions
|
@ -1,7 +1,7 @@
|
||||||
# api/user/management/commands/backfill_user_profiles.py
|
# api/user/management/commands/backfill_user_profiles.py
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from api.user.models import UserProfile
|
from api.user.models import UserProfile # assuming you have a UserProfile model
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
|
|
|
@ -30,13 +30,9 @@ class UserSerializer(serializers.ModelSerializer):
|
||||||
|
|
||||||
# Update the UserProfile instance
|
# Update the UserProfile instance
|
||||||
if profile_data:
|
if profile_data:
|
||||||
userprofile_instance = (
|
userprofile_instance = instance.userprofile # The related UserProfile instance
|
||||||
instance.userprofile
|
|
||||||
) # The related UserProfile instance
|
|
||||||
profile_serializer = self.fields["profile"] # Get the nested serializer
|
profile_serializer = self.fields["profile"] # Get the nested serializer
|
||||||
profile_serializer.update(
|
profile_serializer.update(userprofile_instance, profile_data) # Update the UserProfile
|
||||||
userprofile_instance, profile_data
|
|
||||||
) # Update the UserProfile
|
|
||||||
|
|
||||||
# Update the User fields
|
# Update the User fields
|
||||||
for attr, value in validated_data.items():
|
for attr, value in validated_data.items():
|
||||||
|
|
Loading…
Add table
Reference in a new issue