Andy, I couldn't manage it. Could you (please) give me some example?
It looks like this case is NOT simple at all, googling through
multiple websites didn't bring anything even close to required
solution.
MODEL:
class Property(models.Model):
name = models.CharField(max_length=200)
category =models.ForeignKey(PropertyCategory)
city =models.ForeignKey(City)
status=models.ForeignKey(PropertyStatus)
def __unicode__(self):
return
self.name
VIEW:
def search(request):
q=request.GET['city']
c=request.GET['category']
s=request.GET['status']
properties = Property.objects.filter( HERE_COMES_WHAT_IM_LOOKING_FOR)
HTML:
<form action="/search/" method="get">
<select name="city">
<option value=>ALL</option>
<option value="1">Tokyo</option>
<option value="2">Nashville</option>
</select>
<select name="category">
<option value=>ALL</option>
<option value="1">House</option>
<option value="2">Apartment</option>
</select>
<select name="status">
<option value=>ALL</option>
<option value="1">For Sale</option>
<option value="2">For Rent</option>
</select>
<input type="submit" value="Search">
</form>
...and now I want to display i.e.
all from Tokyo or
all Houses or
all For Sale in Tokyo
etc...