Friday, November 2, 2012

Help with Custom model field and Custom validation for EmailField().

Hi,

I am new to Django. Went through docs before posting this.. I have a model and form like this.

models.py:

class Recipients(models.Model):
     dev = models.EmailField()
     qa = models.EmailField()
     cc = models.MultipleEmailField()

forms.py:

class RecipientsForm(forms.ModelForm):

    class Meta:
        model = Recipients


Now I want to,

1. Add *additional* validation for models.EmailField(). Something like check if email id entered exists in LDAP db.
2. Create new model custom field MultipleEmailField(), which would split emails separated by comma and uses modified validation of models.EmailField() done in step 1.

I am going through docs, but not able to figure out how to put things together! Here is what I understood.

MultipleEmailField() should go in <project-name>/fields.py. But how to make it to run default validation of models.EmailField() and than do custom validation?


Any help appreciated..


Thanks. Dilip

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/aIny3y7HPS4J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment