Not sure what\'s going on here. I\'m trying to perform create a new instance via Django-rest-framework. What am I doing wrong?
There are a few read-
Maybe try something like this in your serializer,
class ClassificationLabelListSerializer(serializers.ModelSerializer):
lastChanged = serializers.DateTimeField(read_only=True)
identifier = serializers.CharField(read_only=True)
revision = serializers.IntegerField(read_only=True)
class Meta:
model = ClassificationLabel
fields = ('displayName', 'helpText', 'identifier', 'backgroundColour', 'foregroundColour', 'comment', 'description', 'lastChanged', 'revision')
def create(self, validated_data):
return ClassificationLabel.objects.create(**validated_data)
Also, edit the save method in your models.py,
def save(self, *args, **kwargs):
self.revision += 1
return super(ClassificationLabel, self).save(*args, **kwargs) #