I have a Model; class Funcionario(models.Model): nome = models.CharField(max_length=200) email = models.CharField(max_length=100) data_nasc = models.DateField('Data de Nascimento') salario = models.FloatField() observacao = models.CharField(max_length=500)
I have a ModelForm for this Model class FuncionarioForm(ModelForm): email = MyEmailField() class Meta: model = Funcionario def clean_email(self): data = self.cleaned_data['email'] if data != 'meuem...@gmail.com': raise forms.ValidationError("ops, cleanEmail") return data And I have a FormSet for this same Model class FuncionarioFormSet(BaseModelFormSet): def __init__(self, *args, **kwargs): self.queryset = Funcionario.objects.all() super(FuncionarioFormSet, self).__init__(*args, **kwargs) Validation for the ModelForm goes fine: When I call the is_valid() method from FuncionarioForm django does: 1. First calls the clean() method of each Field. 2. Calls the clean_email() method on FuncionarioForm 3. Call the clean() method on FuncionarioForm What I want it´s that steps above be repeated on validation of FuncionarioFormSet. Django actually does this according my code: When I call the is_valid() method from FuncionarioFormSet Django does: 1. Calls the clean() method of each Field. 2. Call the clean() method of FuncionarioFormSet. It´s possible create clean_field methods for the validation of a ModelFormSet? --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---