I have a form with two fields

class TestForm (forms.Form):
        EVENT_TYPE_CHOICES = ( ( "", "---Please Select---"),
("01","Individual"), ("02","Team") )
        eventtype =
forms.CharField(max_length=2,choices=EVENT_TYPE_CHOICES)
        participants = forms.IntegerField(required=False, initial=1)

I want to check that if the event type is 01, then the partipants are
not greater than 1.

So, i decided to implement a method

       def clean_participants (self):
               pcd = self.cleaned_data['participants'];

               if pcd > 1:
                   et = self.cleaned_data['eventtype']
                   if et == "01":
                          raise ValidationError ("error message")
               return pcd

This works in all cases except one. When the user does not select the
value for eventtype and enters a value greater than 1 in the
particpants, the program craps out saying key 'eventtype' not found in
cleaned data.

Is this a bug? What is the best way to do this?

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