[Fixed]-Create UUID on client and save primary key with Django REST Framework and using a POST

13👍

The id field of the serializer is set as read-only because of the editable=False argument.

Model fields which have editable=False set, and AutoField fields will
be set to read-only by default,

Try declaring it explicitly:

class PersonCreateSerializer(serializers.ModelSerializer):
    # Explicit declaration sets the field to be `read_only=False`
    id = serializers.UUIDField()

    class Meta:
        model = Person
        fields = ('id', 'username', 'email', 'password')

Leave a comment