@Martin

Thank you for your reply.

I tried to do this, but I still get the default error message (the
custom error from the code field works as it should):

from django.db import models
from django.forms import ModelForm
from django import forms

class Prijsvraag(models.Model):
        naam = models.CharField(max_length=60)
        code = models.CharField(max_length=18)
        ingeschreven = models.DateField(auto_now_add=True)
        mail = models.EmailField(unique=True)
        nieuwsbrief = models.BooleanField(default=1)

class PrijsvraagForm(ModelForm):
        class Meta:
                mail = forms.EmailField(error_messages={'required':
'Vul aub een geldig Email adres in', 'invalid': 'Het email adres is
niet geldig'})
                model = Prijsvraag
        def clean_code(self):
                super(PrijsvraagForm, self).clean()
                x = self.cleaned_data['code']
                try:
                        y = Code.objects.all()[0]
                except:
                        raise forms.ValidationError("Er is iets fout
gegaan")
                if x != y.code:
                        raise forms.ValidationError("De code is niet
juist")
                pass
                return x


Rob

-- 
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.

Reply via email to