DRF not catching nor handling IntegrityErrors #8770
-
Hello Everyone! When using For instance: I have this model.
As you can see, this is expecting a positive integer for hectares, and therefore, it will raise an IntegrityError when passing a negative value, like -500. Nonetheless DRF will not catch that error, resulting in a 500 error. I suggest we handle this in the
this is related to https://stackoverflow.com/questions/35290453/django-rest-framework-integity-error-catch |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Never mind, there is already an even better solution: basically: DRF allows you to configure a custom exception handler. Look in that answer for how to. |
Beta Was this translation helpful? Give feedback.
Never mind, there is already an even better solution:
https://stackoverflow.com/a/74504921/5750078
basically: DRF allows you to configure a custom exception handler. Look in that answer for how to.