Override error representation on import model page django

31 views Asked by At

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:

enter image description here

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,

  1. to override import.html under my templates directory, but it didn't worked.
  2. 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.

1

There are 1 answers

2
Matthew Hegarty On

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.