I'm using djangorestframework, and someone makes a PUT request to a .../peoplelist/2/markAsSeen, passing in just a Person object's id in the URL. I fetch the Person object (2 in this case) and then simply change the fetched Person object's field has_been_viewed to True. The updated Person object is then to be serialized and returned back to the client.
if request.method == 'PUT':
serializer = PersonSerializer(person,partial=True)#person is a valid object here
if serializer.is_valid():
serializer.save()
return Response(serializer.data)
else:
return Response(serializer.errors,)
serializer errors is {u'non_field_errors': [u'No input provided']}
serializer.data looks fine to me
class PersonSerializer(serializers.ModelSerializer):
class Meta:
model = Person
fields = ('id',)