1👍
✅
It turns out the error message is a complete red herring. What’s really happening is that there’s an incompatibility between the unique_together
constraint in the Model and read-only
fields like StringRelatedField
defined in the Serializer.
Removing unique_together
from the Model restored the Serializer’s functionality. Alternatively, you could remove the read-only field declaration from the Serializer. Neither really seem like an appropriate solution as they require sacrificing functionality in pretty major ways.
Right now there appears to be an issue open on DRF’s GitHub related to this problem but it remains to be seen if this is Working As Intendedtm or is in fact a bug.
Source:stackexchange.com