I am using jinja2 as a template for a django application. I wanted to make a request in a template. I tried to do this:
{% for f in fs %}
{% Following.objects.filter(follows=f).count() %}
{% endfor %}
I pass "fs" in variables when rendering the templates that are listed.
But it's not right. I cannot make a query_set call because of how my models are defined. Here is a snippet:
class Following(models.Model):
user = models.ForeignKey(User)
follows = models.ForeignKey(F)
class F(models.Model):
name = models.CharField(max_length=50)
So is there a way to do this?
source
share