Re: Custom form field validation and required=False

2010-07-17 Thread Paddy Joy
Thanks for that, using: from django.core import validators . . class ExistingUserField(forms.CharField): def clean(self, value): if value in validators.EMPTY_VALUES: return value did the trick. Paddy On Jul 17, 3:31 am, Nuno Maltez wrote: > Hi, > > Looking at Django's f

Re: Custom form field validation and required=False

2010-07-16 Thread Nuno Maltez
Hi, Looking at Django's forms/fiedls.py may give you some ideas. The test for an empty value is if value in validators.EMPTY_VALUES You can also use self.required to see if the required attribute is set (e.g., see Field's validate() method). Of course, a username with a single space will still

Custom form field validation and required=False

2010-07-16 Thread Paddy Joy
I'm trying to create a custom form field that will validate against auth.user. The field should throw a validation error if the user does not exist, otherwise the field should validate. So far I have: class ExistingUserField(forms.CharField): def clean(self, value): # Check if the use

Re: custom form field validation

2010-07-15 Thread refreegrata
ok, for my problem that don't works because when i set required=False the field isn't evaluated when it is in blank. I want an evaluation for my function in every situation. With required=True and a custom error message an evaluation can be simulated but if i do a code inside the function in that c

Re: custom form field validation

2010-07-15 Thread Oleg Lomaka
http://docs.djangoproject.com/en/1.2/ref/forms/fields/#required usu = forms.CharField(required=False, ...) On Jul 15, 2010, at 5:25 PM, refreegrata wrote: > Hello list. I'm a newie in django with many questions. I want to do > something like this: > --

custom form field validation

2010-07-15 Thread refreegrata
Hello list. I'm a newie in django with many questions. I want to do something like this: def (valor): raise ValidationError("A") class Mm