> from schools.models import School
> def schools(request, country, city)
> schools = School.objects.?
Try this:
schools = School.objects.filter(city__exact=city,
city__country__exact=country)
Basically, use double underscores in the query fields to traverse
through your model heira
Consider the following setup:
Class country holds all country's
Class City holds all city's with a foreignkey to the country
Class schools holds all schools with a foreingkey to city
I want a url like ...school/country/city
In that way I can get a list of all schools in a city from a country.
2 matches
Mail list logo