Custom model field validation in Django
These days I am trying my hand at a rewrite of Dead Man’s Switch, to add more features and generally improve the service.
One of these features was being able to add multiple emails in the “recipients” field, and I wanted to do this as cleanly as possible, so I decided to create a Django model with custom validation. This was not immediately obvious, as the docs didn’t mention much. Eventually I stumbled across this very thing done in the source, and here is my model class, in the hopes that some of you might find it useful:
class MultipleEmailField(models.CharField):
description = ugettext_lazy(“E-mail address”)