You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to created an object from a nested field, using a patch request. Basically there exist one to many relationship between them, and also a unique together constrain at the model level.
When I try to create an object that break the unique together constrain, let's that send again the same payload. The update method, get and an error from the serializer.
Because the data is not valid, It violates the unique together constrain as I expect, but the request return a 500 code with the following message: "AssertionError: You cannot call .save() on a serializer with invalid data" Instead of return serializers.ValidationError.
Is this behaviour what are you expecting?
I would like to handle that error, I think in override the update method and put one try and except in order to catch the ValidationError and return a custom message.
Do you have any suggestion to this?
Thank you!
The text was updated successfully, but these errors were encountered:
I am trying to created an object from a nested field, using a patch request. Basically there exist one to many relationship between them, and also a unique together constrain at the model level.
url: PATCH: http://127.0.0.1:8000/api/v2/product_batches/11791/
Payload:
When I try to create an object that break the unique together constrain, let's that send again the same payload. The update method, get and an error from the serializer.
Because the data is not valid, It violates the unique together constrain as I expect, but the request return a 500 code with the following message: "AssertionError: You cannot call
.save()
on a serializer with invalid data" Instead of return serializers.ValidationError.Is this behaviour what are you expecting?
I would like to handle that error, I think in override the update method and put one try and except in order to catch the ValidationError and return a custom message.
Do you have any suggestion to this?
Thank you!
The text was updated successfully, but these errors were encountered: