Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View mrmuxl's full-sized avatar

mrmuxl mrmuxl

View GitHub Profile

Full e-mail address validation for Django

Out of the box, Django e-mail fields for both database models and forms only accept plain e-mail addresses. For example, joe@hacker.com is accepted.

On the other hand, full e-mail addresses which include a human-readable name, for example the following address fails validation in Django:

import logging
logger = logging.getLogger(__name__)
# Note: we need dnspython for this to work
# Install with `pip install dnspython`
import dns.resolver, dns.exception
from django import forms
from django.utils.translation import ugettext as _
ff="/tmp/monsterwm.fifo"
[[ -p $ff ]] || mkfifo -m 600 "$ff"
# desktop names
ds=("web" "dev" "foo" "null")
# layout names
ms=("T" "M" "B" "G" "F")
while read -t 60 -r wmout || true; do