I'm using Django trunk r7047. This is my code

prj/validators.py
===========
from django.core.validators import ValidationError

class StringLengthIs(object):
    def __init__(self, length, error_message=''):
        self.length = length
        if not error_message:
            self.error_message = _("This string length must be %s.") %
length
        else:
            self.error_message = error_message

    def __call__(self, field_data, all_data):
        val = len(field_data)

        if val != self.length:
            raise ValidationError(self.error_message)

prj/app/models.py
=============
from prj.validators import StringLengthIs

class Foo(models.Model):
    name = models.CharField(validator_list=[StringLengthIs(6)])

prj/app/forms.py
============
from prj.app.models import Foo

class FooForm(forms.ModelForm):
    def clean_name(self):
        # This isn't run
        pass
    def clean(self):
        # This is run
        pass
    class Meta:
        model = Foo

--
when I save() a Foo instance StringLengthIs(6) is not run. Besides,
when I call is_valid() to a FooForm instance clean() is called but
clean_name() isn't called.

What I'm doing wrong?

Regards,
maykel

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to