1
You cannot do queryset filters in templates. You might want to create a manager which can be called from the template, or create a property on the model for table which can been called.
Example
class Table(models.Model):
#more fields
@property
def unoccupied_count(self):
return self.seat_set.filter(occupied=False).count()
and in the templates,
{{ table.unoccupied_count }}
Source:stackexchange.com