Validating email without EmailField

Posted: January 25th, 2010 | Author: Davo | Filed under: Django | Tags: , , | No Comments »

Sometimes it is handy to test if a given string is a valid email without having EmailField or Form.
The following function can be used to validate an email.

from django.core.validators import email_re

def is_valid_email(email):
    if email_re.match(email):
        return True
    return False