Building Django 1.8 app which is like a photo gallery (my galleries are called 'fountains'). I have a page with list of fountains and I want to show the count of photos beside the fountain name eg:

```
Fountain 1 (49 photos)
Fountain 2 (43 photos)
etc

```

I understand that Django has annotate to aggregate and count records that I have used to create the following: 

```
 photo_count = Fountains.objects.all().annotate(Count('photos'))

```

However, what I cannot determine is where to put this. The documentation just shows the query but doesn't place the query and resulting counts in the context of an application.

I have done this 'photo\_count' aggregation in the view that creates the data for the list of fountains. 

But my question is, how to get this into the template so it can be shown beside the fountain name?

I guess i have to load it into the template and then associate it with the fountain pk?

Any pointers on what the Django methodology is to get this aggregation from view into the template would be greatly appreciated!

My models:

```
class Fountains(models.Model):
    foun_name = models.CharField(max_length=100, blank=True, null=True)
    foun_desc = models.TextField(blank=True, null=True)
    foun_address = models.CharField(max_length = 100, blank=True, null=True)
    foun_lat = models.CharField(max_length=20, blank=True, null=True)
    foun_lon = models.CharField(max_length=20, blank=True, null=True)
    created = models.DateTimeField(auto_now_add=True)
    modified = models.DateTimeField(auto_now=True)
    #tags = TaggableManager()
    #def __unicode__(self):
    #    return self.foun_name.name

    class Meta:
        managed = True
        db_table = 'fountains'
        #verbose_name_plural = 'Fountains'

class Photos(models.Model):
    #filename = models.CharField(max_length=100)
    filename = models.ImageField(upload_to='.')
    ext = models.CharField(max_length=5, blank=True, null=True)
    desc = models.TextField(blank=True, null=True)
    #fountain_id = models.IntegerField(blank=True, null=True)
    fountain = models.ForeignKey(Fountains)
    user_id = models.IntegerField(blank=True, null=True)
    tag_count = models.IntegerField(blank=True, null=True)
    photos_tag_count = models.IntegerField(blank=True, null=True)
    comment_count = models.IntegerField(blank=True, null=True)
    created = models.DateTimeField(auto_now_add=True)
    modified = models.DateTimeField(auto_now=True)
    #def __unicode__(self):
    #    return self.filename.name

    class Meta:
        managed = True
        db_table = 'photos'
        #verbose_name_plural = 'Photos'

```

My view that creates the list of fountains:

```
@login_required
def fountains(request):
    assert isinstance(request, HttpRequest)
    fountain_list = Fountains.objects.order_by('foun_name')
    photo_count = Fountains.objects.all().annotate(Count('photos'))
    context_dict = {'fountains': fountain_list }
    return render(
        request,
        'app/fountains.html',
        context_dict,
        context_instance = RequestContext(request)
    )

```

My template that displays the view results:

```
{% extends "app/layout.html" %}

{% block content %}

    <h1>Fountains</h1>
    <p><a href="/fountain_add/">Add Fountain</a></p>
    <ul>
    {% for fountain in fountains %}
        <li><a href="/photos/{{ fountain.id }}/"}>{{ fountain.foun_name }}</a></li>
    {% endfor%}
    </ul>

{% endblock content %}

```