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

2012-11-06 Thread Dilip M
Hi Abraham, This is beautiful & is of huge help! thank you. :) I created a new file named /validators.py and add the below code. from django.core.validators import EmailValidator from django.core.exceptions import ValidationError def multi_email_validator(value): if value and "," in value:

RE: Help with Custom model field and custom validation for EmailField()

2012-11-03 Thread bb6xt
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

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

2012-11-03 Thread Chris Pagnutti
I've never done it myself, but I think you'd just define the clean method in your Form's class (i.e. in forms.py), and the first line in your clean() method should call the parent classes, clean() method - to do this you need to call the super() method, which is just regular python. It think the c

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

2012-11-03 Thread Dilip M
Hi Chris, Thank you very much for your time on this. I am not able to make out on how could I put this under clean() method. Ex: What does "you must call the*parent class's clean() "* mean in "if you would like to override the clean() method and maintain the _default validation_, you must call the

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

2012-11-02 Thread Chris Pagnutti
Ahh. Just saw your link to overriding the clean() method. So you could put all the same logic above into the clean() method instead. On Friday, November 2, 2012 4:36:20 AM UTC-4, Dilip M wrote: > > Hi, > > I am new to Django. Went through docs before posting this.. I have a model > and form li

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

2012-11-02 Thread Chris Pagnutti
Again, I'm not sure, but I think to do it at Model validation level you'd have to modify some of the django core files themselve. I think what you're looking for is in django.core.validators (in my install this file is at /lib/python2.7/site-packages/django/core/validators.py, or you can just

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

2012-11-02 Thread Dilip M
On Fri, Nov 2, 2012 at 5:52 PM, Chris Pagnutti wrote: > Hi. I'm pretty new to Django too, so someone else probably has a better > idea. But I think that on the server side, you can handle additional > validation in the view that handles the form submission (i.e. the view that > the "action" attr

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

2012-11-02 Thread Chris Pagnutti
Hi. I'm pretty new to Django too, so someone else probably has a better idea. But I think that on the server side, you can handle additional validation in the view that handles the form submission (i.e. the view that the "action" attribute in your form points to). You can probably attach err

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

2012-11-02 Thread Dilip M
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):