I have a model as bellow:
class Artwork(models.Model):
title = models.CharField(max_length=120)
collection = models.CharField(max_length=120,null=True)
slug = models.SlugField(blank=True, unique=True)
description = models.TextField()
price = models.DecimalField(decimal_places=2, max_digits=20, default=0)
image = models.ImageField(upload_to=upload_image_path, null=True, blank=True)
banner = models.ImageField(upload_to='artworks/banner')
video = models.FileField(upload_to='artworks/video',blank=True,null=True)
category = models.CharField(choices=CATEGORY_CHOICES, max_length=15)
views_count = models.IntegerField(default=150)
featured = models.BooleanField(default=False)
active = models.BooleanField(default=True)
created = models.DateTimeField(default=timezone.now)
and The view as bellow:
def artwork_list_view(request):
queryset = Artwork.objects.all()
context = {
'objet_list':queryset,
}
return render(request, "artworks/list.html", context)
I use the queryset in template as bellow:
<div style='min-height:80px;'><p >First Collection</p></div>
{% for obj in object_list %}
<div class="workSeriesThumbnailStrip">
{% if obj.image %}
<a href="{{ obj.get_absolute_url }}"><img src="{{ obj.image.url }}" style="float:left;width:67px;height:87px;margin:10px;" ></a>
{% endif %}
</div>
{% endfor %}
</div>
know I have more than one collection and want to place a for loop in collections to show items of each collection in one row. But as I'm new in django, I don't know how to retrieve the list of collections and pass them to template. please help me.
There is a typo in the
object_listkey