[Answered ]-Django-rest-framework: serializer.save doesn't return object's id

1👍

Ouch. I’m sorry for this question.
Somebody created pk field for this table as integer with default value from sequence (without owning this sequence).
Django performs pk selection as SELECT CURRVAL(pg_get_serial_sequence('tablename','id')). But pg_get_serial_sequence returns Null.
I don't know why django-rest-framework doesn't perform
select … returning id;`. I’ll try to fix the database.

1👍

I think this serializer class should work:

class PlatformSerializer(serializers.ModelSerializer):
    class Meta:
        model=Platform

ModelSerializer:

By default, all the model fields on the class will be mapped to corresponding serializer fields.

Leave a comment