[0] is missing in _get_response_json_from_error_message
nico-deforge opened this issue · comments
Hello,
First, thank you for your styleguide, it helps me to be a better Django developer.
I am particularly interest by your custom error formatter and I think i have found a bug.
I think [0] is missing in _get_response_json_from_error_message
It is not bas because it works but mypy raise an exception.
def _get_response_json_from_error_message(
self, *, message: str = "", field: Optional[str] = None, code: str = "error")
-> Dict[str, List[Dict[str, str]]]:
response_data: Dict[str, List[Dict[str, str]]] = {
self.ERRORS: [{self.MESSAGE: message, self.CODE: code}]
}
if field:
response_data[self.ERRORS][0][self.FIELD] = field
return response_data
If it could help you, i will be happy.
@nico-deforge Thanks for this!
To be honest, this error handling is a leftover artifact from older projects.
We need to step in & update it with what we are currently using.
So thanks for bringing this up, we should get up to speed.
Ok, I will be happy to discover what you are currently using because I like the way you are designing django apps :)