django-import-export icon indicating copy to clipboard operation
django-import-export copied to clipboard

How to add error message when `UNIQUE constraint failed`

Open wgf4242 opened this issue 3 years ago • 2 comments

when import twice get a long Traceback (most recent call last):

class Employee(models.Model):
  id_number = models.CharField(max_length=180, null=True, blank=True, unique=True)

I want to show the error like admin default error message, like already exist Employee with this _id_number

wgf4242 avatar May 27 '22 01:05 wgf4242

I suggest search back over previous issues and Stack Overflow (if not already). If you're still stuck, please come back with more details about your setup and what you're trying to achieve. The more information you give us, the more likely it is we'll be able to help.

matthewhegarty avatar May 27 '22 11:05 matthewhegarty

When add same id_number trigger UNIQUE constraint .

Django admin give a friendly error message when id number is not unique.

django-import-export give a Exception Traceback .

I want django-import-export give a friendly error message, how to do this?


Django admin error message

image


django-import-export error message

image

wgf4242 avatar May 27 '22 17:05 wgf4242

This may help: https://github.com/django-import-export/django-import-export/issues/1257#issuecomment-952276485

matthewhegarty avatar Oct 31 '22 10:10 matthewhegarty

Closing due to inactivity

matthewhegarty avatar Apr 12 '23 13:04 matthewhegarty