I am trying to partially update a record using (partial=True) via my serializer, however, when I look at the sql update statement, it's showing that all fields are being updated when only a subset of fields are being submitted.
class Setting(models.Model):
comments_enabled = models.BooleanField(default=True)
visibility = models.CharField(max_length=50, choices=VISIBILITIES,
blank=False, null=False,
default=VISIBILITY_CHOICE_PARTICIPANTS)
modified = models.DateTimeField(auto_now=True, blank=True, null=True)
class SettingsSerializer(serializers.ModelSerializer):
class Meta:
model = Setting
fields = ('id', 'comments_enabled', 'visibility', 'modified')
class SomeSerializer(serializers.ModelSerializer):
def update(self, instance, validated_data):
settings_serializer = SettingsSerializer(instance.settings, data=validated_data.get('settings'), partial=True)
settings_serializer.is_valid(raise_exception=True)
settings_serializer.save()
I have doubled checked that the validated_data dictionary being passed in only has one field.
I'm using DRF 3.3 and Django 1.9