[Answer]-Using Django Template, how to properly retrieve values that contain brackets in the reference?

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 }}

Leave a comment