To create a new Customer (User), we send a POST to /api/v1/customers/. The view for this looks like:
The POST includes username and password, along with some optional fields (e.g. gender).
We can edit a Customer (User) by sending a PUT to /api/v1/customers/<id>/. The view for this is just:
class CustomerDetail(generics.RetrieveUpdateDestroyAPIView):
queryset = Customer.objects.all()
serializer_class = CustomerSerializer
However, if I want to change the gender for a Customer, I need to send the password field again - we'd like to just be able to send the gender.
Is there some way to make Customer.Password require for the initial POST, but then make it optional for PUT?
(And ideally, we'd also like to hide it from GETS to /api/v1/customers/<id>/ - as in, we don't want this one to return the password hash.).
I was thinking of just creating a second Customer Serializer and using it for the Detail view, but not sure if that's a bit hacky? Also, password field is required on the model level, so not sure how that would work.
Cheers,
Victor