I have a simple Model
that stores the user that created it with a ForeignKey
. The model has a corresponding ModelSerializer
and ModelViewSet
.
The problem is that when the user submits a POST
to create a new record, the user
should be set by the backend. I tried overriding perform_create
on the ModelViewSet
to set the user, but it actually still fails during the validation step (which makes sense). It comes back saying the user
field is required.
I'm thinking about overriding the user
field on the ModelSerializer
to be optional, but I feel like there's probably a cleaner and more efficient way to do this. Any ideas?