Hi, I am wondering if it's possible to link dropdowns using newforms. I want to use the selected value in the first dropdown as the filtervalue for the next dropdown etc.
My model looks something like this: /////// models.py class Property(models.Model): """ Contains a list of properties that can be reused in several property/value combinations. Category is the "top" property.""" property_name = models.CharField() class PropertyValueCombo(models.Model): """ Combines property with a value in a Combo that are the buildingblocks that makes up the Individuals.""" property_name = models.ForeignKey(Property) value_word = models.CharField(null = True, blank = True) value_text = models.TextField(null = True, blank = True) value_date = models.DateField(null = True, blank = True) parent_combo = models.ForeignKey('self', null = True, blank = True, related_name = 'parent_combo_child_set') hybrid_parent_combo = models.ForeignKey('self', null = True, blank = True, related_name = 'hybrid_parent_combo_child_set') def __unicode__(self): return '%s %s %s' % (self.value_word, self.value_text, self.value_date) class Individual(models.Model): """ These objects represent the individual plants and animals that are registered in the database.""" combo = models.ManyToManyField(PropertyValueCombo, filter_interface = models.HORIZONTAL) parent_individual = models.ForeignKey('self', null = True, blank = True, related_name = 'parent_individual_child_set') index_id = str(id) def __unicode__(self): return self.index_id //////// views.py class FirstColumnForm(forms.Form): alla_combo = PropertyValueCombo.objects.all() val = [] for instance in alla_combo: test=unicode(instance.property_name) if test=='Category': val.append(instance.value_word) category = forms.MultipleChoiceField(choices=[(c, c) for c in val]) def first_column(request): if request.method == 'POST': kolumn_1 = FirstColumnForm(request.POST) selected_category = request.POST['category'] return render_to_response('search.html',{'kolumn_1':kolumn_1, 'selected_category':selected_category}) else: kolumn_1 = FirstColumnForm() return render_to_response('search.html', {'kolumn_1':kolumn_1}) /////// The form produces a MultipleChoiceField (MCF) and the user is able to select a value. The value is then presented next to the first MCF. The next step would be to use the selected value as the filtervalue for the second column, but this is where I've run into trubble. I've tried to create a second form class for the second column, but I then got an error saying that the form class had unknown parameters. Since the class is validated before any value is selected ie the selected parameter is unknown. I also have a second problem, which is that my first column will display the wrong set of data when the request change. Anybody have a better suggestion how I should go about displaying the data? This might to a great extent be connected to the first problem... I have been looking like crazy for a solution, but I still don't know how to proceed. I would greatly appreciate if anybody could give me a hint in the right direction (if there is one...) Thanks in advance. Emma --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---