I'm working with a django application and don't wanted to show users the stack trace when there is any error occurred in production.
For example, I've added validation to validate import action under before_import
method, and when there is any issue in the validation it shows error message along with stack trace. Please refer screenshot below:
Instead I wanted to just show the error message only. This is mainly for the security purpose as on production it will disclose my server directory structure to it's users.
I tried couple of things,
- to override
import.html
under my templates directory, but it didn't worked. - to override exception using LOGGING in settings.py
It is great, if I can show list of errors for all affected rows in a CSV/XLSX file.
Yes, you can control the formatting of the error message if required. Please refer to the docs.
I also recently updated the documentation about best practices with validation. In your example, you could consider writing a custom widget to do the coupon validation.