class Album(models.Model):
title = models.CharField(max_length=255)
caption = models.CharField(max_length=1000)
slug = models.SlugField(primary_key=True, unique=True)
class Image(models.Model):
image = models.ImageField(upload_to='albums/')
title = models.CharField(max_length=255)
caption = models.CharField(max_length=1000)
album = models.ForeignKey(Album)
{% for album in albums %}
<div class="album-{{ album.pk }}">
{% for image in album.image_set.all %}
<div class="image-{{ image.pk }}>
<img src="{{ image.image.url }}}" alt="Image was here"/>
</div>
{% endfor %}
</div>
{% endfor %}