Reputation: 138
I created User model in Django as:
email = models.EmailField(
verbose_name="Email Address", unique=True, null=True, blank=True)
When I try to register user with same email it show message user with this Email Address already exist, how can I customize this message to User with this email exist
Upvotes: 0
Views: 194
Reputation: 8837
You can use unique
attribute of error messages dict and customize it according to your custom message (User with this email exist) so:
class User(models.Model):
email = models.EmailField(
verbose_name="Email Address", unique=True,
error_messages={
'unique': 'User with this email exists.',
}
)
Upvotes: 1
Reputation: 73
As per my understanding of the problem, below answer should solve the issue
models.EmailField(
verbose_name="Email Address", unique=True, null=True, blank=True,
error_messages={
'unique': "User with this email already exists.",
}
)
Upvotes: 1