Hi,

I am doing custom validation in my form class's clean() method
according to several fields in the form but some fields does not
appear in the cleaned_data dictonary when the supplied value is
empty.


My (simplified) model is:

class Event(models.Model):
    title = models.CharField(max_length=150)
    description = models.TextField(blank=True, null=True)
    start = models.DateTimeField(db_index=True)
    end = models.DateTimeField(blank=True, null=True)


And my form class is:

class EventForm(forms.ModelForm):
    start = SplitDateTimeField(widget=SplitDateTimeWidget())
    end = SplitDateTimeField(widget=SplitDateTimeWidget())

    class Meta:
        model = Event

    def clean(self):
        try:
            Event.objects.get(title=self.cleaned_data['title'],
 
start__year=self.cleaned_data['start'].year,
 
start__month=self.cleaned_data['start'].month,
 
start__day=self.cleaned_data['start'].day)
        except Event.DoesNotExist:
            return self.cleaned_data
        else:
            raise ValidationError(_('This event already exists'))


When I submit the form with all-empty values and debug, there is no
self.cleaned_data['title'] in the form class's clean() method's
context, but there is self.cleaned_data['description'], for example.


Am I missing something?


Thanks...

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