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