ye_qca
Last Updated: January 23, 2019
·
22.81K
· leech

Validate email address in Django

from django.core.validators import email_re

if email_re.match(email_address):
    # Email valid!
else:
    # Email not valid!

It's used by the EmailField validation, but you can use anywhere.

2 Responses
Add your response

17893

thats deprecated now. use:

from django.core.validators import validate_email
try:
    validate_email(username)
    valid_email = True
except validate_email.ValidationError:
    valid_email = False
over 1 year ago ·
17894

@radlws Thanks for the update!

over 1 year ago ·