Last Updated: January 23, 2019
·
35.67K
· 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

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 ·

@radlws Thanks for the update!

over 1 year ago ·