Django+Postgres Broken transaction after checking for uniqueness

Viewed 15

I created a simple project with one application and a model. https://github.com/SergeyMalash/test_unique

It has two unique fields. Also in the settings I specified ATOMIC_REQUESTS When I make a POST request with an invalid IP address, an error occurs (screenshot)

My assumptions: As far as I understand, during the check for uniqueness, a DataError exception occurs, since postgres can't compare inet field with an incorrect IP address This breaks all subsequent calls to the database. https://github.com/encode/django-rest-framework/blob/master/rest_framework/validators.py#L71

Am I right? How can this be fixed? I need to leave ATOMIC_REQUESTS enabled

My issue is partially related to https://github.com/encode/django-rest-framework/issues/3381
But I didn't find a solution there.

`https://pastebin.com/bDuQvje4`
`https://pastebin.com/7VaWjMaZ`

enter image description here

0 Answers
Related