Use of perform_create in REST framework tutorial

I have a question regarding the rest framework tutorial regarding the owner field.

I tried to have a similar application where the owner field is populated automatically from the logged in user, and not provided as a POST field.

def perform_create(self, serializer):
    serializer.save(owner=self.request.user)

I see that in the tutorial, the perform_create function is user to provide the owner. However, I see in the request that the owner field is supplied

http -a admin:password123 POST http://127.0.0.1:8000/snippets/ code="print(789)"

{
    "id": 1,
    "owner": "admin",
    "title": "foo",
    "code": "print(789)",
    "linenos": false,
    "language": "python",
    "style": "friendly"
}

I tried on my own application not to supply the owner field but then I have an error mentioning that the field is mandatory. I think the serializer fails at the validation step.
Do I have a good understanding of this and what should I do to avoid having to supply the owner field in the request?

Thank you!

1 Like