{"action":"created","issue":{"url":"https://api.github.com/repos/encode/django-rest-framework/issues/6124","repository_url":"https://api.github.com/repos/encode/django-rest-framework","labels_url":"https://api.github.com/repos/encode/django-rest-framework/issues/6124/labels{/name}","comments_url":"https://api.github.com/repos/encode/django-rest-framework/issues/6124/comments","events_url":"https://api.github.com/repos/encode/django-rest-framework/issues/6124/events","html_url":"https://github.com/encode/django-rest-framework/issues/6124","id":350435661,"node_id":"MDU6SXNzdWUzNTA0MzU2NjE=","number":6124,"title":"Raising of 409 Conflict code","user":{"login":"vdusek","id":25082181,"node_id":"MDQ6VXNlcjI1MDgyMTgx","avatar_url":"https://avatars1.githubusercontent.com/u/25082181?v=4","gravatar_id":"","url":"https://api.github.com/users/vdusek","html_url":"https://github.com/vdusek","followers_url":"https://api.github.com/users/vdusek/followers","following_url":"https://api.github.com/users/vdusek/following{/other_user}","gists_url":"https://api.github.com/users/vdusek/gists{/gist_id}","starred_url":"https://api.github.com/users/vdusek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vdusek/subscriptions","organizations_url":"https://api.github.com/users/vdusek/orgs","repos_url":"https://api.github.com/users/vdusek/repos","events_url":"https://api.github.com/users/vdusek/events{/privacy}","received_events_url":"https://api.github.com/users/vdusek/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-08-14T13:46:25Z","updated_at":"2018-08-14T18:56:10Z","closed_at":null,"author_association":"NONE","body":"## Description\r\nWhen a unique constraint is violated status code is ```400 Bad Request```. Instead, I'd like ```409 Conflict``` to be raised.\r\n\r\n## Expected behavior\r\nI am able to subclass some of the DRF exception to raise my own ```status_code``` and my own error ```detail```.\r\n\r\n## Actual behavior\r\nWhen I create a subclass of [ValidationError](https://github.com/encode/django-rest-framework/blob/master/rest_framework/exceptions.py#L142) I can configure my own ```detail``` and it works fine. However when I want to configure my own ```status_code```, it doesn't work at all and ```400 Bad Request``` is raised anyway.\r\n\r\nWhen I create a subclass of [APIException](https://github.com/encode/django-rest-framework/blob/master/rest_framework/exceptions.py#L98) my ```status_code``` is raised properly, but ```detail``` is wrong formated. It's not in a ```{'key': ['error detail', ...]}``` format.\r\n"},"comment":{"url":"https://api.github.com/repos/encode/django-rest-framework/issues/comments/412979225","html_url":"https://github.com/encode/django-rest-framework/issues/6124#issuecomment-412979225","issue_url":"https://api.github.com/repos/encode/django-rest-framework/issues/6124","id":412979225,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMjk3OTIyNQ==","user":{"login":"tomchristie","id":647359,"node_id":"MDQ6VXNlcjY0NzM1OQ==","avatar_url":"https://avatars2.githubusercontent.com/u/647359?v=4","gravatar_id":"","url":"https://api.github.com/users/tomchristie","html_url":"https://github.com/tomchristie","followers_url":"https://api.github.com/users/tomchristie/followers","following_url":"https://api.github.com/users/tomchristie/following{/other_user}","gists_url":"https://api.github.com/users/tomchristie/gists{/gist_id}","starred_url":"https://api.github.com/users/tomchristie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomchristie/subscriptions","organizations_url":"https://api.github.com/users/tomchristie/orgs","repos_url":"https://api.github.com/users/tomchristie/repos","events_url":"https://api.github.com/users/tomchristie/events{/privacy}","received_events_url":"https://api.github.com/users/tomchristie/received_events","type":"User","site_admin":false},"created_at":"2018-08-14T18:56:10Z","updated_at":"2018-08-14T18:56:10Z","author_association":"MEMBER","body":"Sure. Worth having a search through the issues for ‘409’. Short version is that we can’t *really* provide different error codes for different types of field error, because serializers can include multiple field errors."}}
{"actor":{"display_login":"tomchristie"}}