##CODE 1:
from models import City, Zone
class SearchForm1(forms.Form):
cityf = forms.ModelChoiceField(queryset=City.objects.all(), empty_label="none")
zonef = forms.ModelChoiceField(queryset=Zone.objects.all(), empty_label="none")
---------------------------------
##CODE 2:
class SearchForm1(forms.Form):
cityf = forms.ModelChoiceField(queryset=City.objects.all(), empty_label="none")
zonef = forms.ModelChoiceField(queryset=City.objects.get(name_city="cityf").zone_set.all(), empty_label="none")
---------------------------------
But I recive this
##ERROR:
Exception Type: DoesNotExist
Exception Value:
City matching query does not exist.
Exception Location:
/usr/local/lib/python2.6/dist-packages/django/db/models/query.py in
get, line 349
------------------------------------
Comments