bb...@yahoo.com
unread,Nov 4, 2012, 1:16:26 AM11/4/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
Hi,
If all u nid is a field whose value is a comma separated list of emails den u dont nid a custom field at all. All u nid is a gud ol CharField. Just set it like so:
emails=models.CharField(max_length=500, validators=[multi_email_validator,]).
here is what multi_email_validator looks like:
from django.core.validators import EmailValidator
from django.core.exceptions import ValidationError
def multi_email_validator(value):
if value and "," in value:
for v in value.split(",").strip():
try:
EmailValidator().__call__(v)
except: raise ValidationError("%s is not a valid email" % v)
else:
try:
EmailValidator().__call__(value)
except: raise ValidationError("%s is not a valid email" % value)
with dis aproach and using modelforms u dont nid to validate in forms or views cos calling form.is_valid with call model field validators too. Hope dis helps.
abraham.
--------------------------
Sent from my mobile device