Relative Content

Tag Archive for djangodjango-modelslocalization

How to localize Django duplicate key value violates unique constraint error message?

Problem description I would want to provide clear localized error messages to client using Django. I have the following unique field: class Foo(models.Model) email = models.EmailField(max_length=255, unique=True, default=None, blank=True, null=True, verbose_name=gettext_lazy(’email address’), error_messages={‘unique’: gettext_lazy(“Email address is already registered to another user.”)}) When I try to save duplicate email address, I still get an error psycopg2.errors.UniqueViolation: […]