[Fixed]-Update nested field

1👍

You didn’t call save on related object

def update(self, instance, validated_data):
    instance.movie.name = validated_data.get('movie', {}).get('name') or instance.movie.name 
    instance.watched_full = validated_data.get('watched_full', instance.watched_full)
    instance.rating = validated_data.get('rating', instance.rating)
    instance.source = validated_data.get('source', instance.source)
    instance.video_quality = validated_data.get('video_quality', instance.video_quality)
    instance.watched_at = validated_data.get('watched_at', instance.watched_at)
    # here
    instance.movie.save()
    instance.save()

    return instance

Leave a comment