You would never be able to achieve downloads_list.downloadItemSample_set
as downloads_list
is a queryset.
One way to achieve this would be:
{% for download in downloads_list %}
{{ download.get_sample_by_order }}
{% endfor %}
Here get_sample_by_order
is a helper method in the class DownloadItem
which returns the value we need.
class DownloadItem(models.Model):
name = models.CharField(max_length=200)
description = models.CharField(max_length=200)
downloadItem = models.ImageField(upload_to='./images/downloadItems', blank=True)
def __unicode__(self):
return self.name
def get_sample_by_order(self):
if self.downloaditemsample_set.count():
return self.downloaditemsample_set.order_by('order')[0]