I have a form that has three fields 1. State 2. League 3. School The model for League has a foreign Key into the model for State The model for School has a foreign Key into the model for League
The user is supposed to chose the state first (which is USStateField), then the list of League is supposed to get populated. The use is supposed to choose the League which is supposed to populate the choices of School for the user to select. The user finally is supposed to select school. The three fields are as follows: state = USStateField(required=True,widget=USStateSelect) league = forms.ModelChoiceField(queryset=League.objects.none(), empty_label="Please select state first", cache_choices=True, required=False, label="League") school = forms.ModelChoiceField(queryset=School.objects.none(), empty_label="Please select league first", cache_choices=True, required=False, label="School") I have the JS implemented that populates the fields dynamically based on user selection and that is working fine. My questions are as follows: 1. If I select the three fields, and submit the form, I get back an error saying "Select a valid choice. That choice is not one of the available choices." for both the League and School fields. So, basically the values are not sticking to the form. I guess this is because my queryset specifies League.objects.none(). How do I make the values bind to the fields without having to resort to changing the queryset to League.objects.all(). I don't want to do this cos the League data is huge. 2. Since the fields don't bind to the values, when the form get redisplayed, the values are not redisplayed. I am struggling with the ModelChoiceField in general as well. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---