Hi All -
I'm probably overlooking something. Using the mezzanine thumbnail tag I am
trying to thumbnail all related images in my object list. However, only the
last image in the set gets thumbnailed.
I've never seen this before. I am wondering if it's because I am using
prefetch_related.
Below is my code. Please let me know if anything wrong stands out.
Thanks
models.py
> class Category(Page):
> """
> A category for grouping listings into a series.
> """
>
> pass
>
>
> class Listing(Orderable, Displayable, RichText, BaseListing):
> categories = models.ManyToManyField("Category",
> verbose_name=_("Categories"),
> blank=True, related_name="categories")
> ...
>
>
> class ListingImage(Orderable):
> listing = models.ForeignKey("Listing", related_name="images")
> file = models.ImageField(_("File"), max_length=200,
> upload_to=listing_directory_path)
> description = models.CharField(_("Description"), max_length=1000,
> blank=True)
>
> cropping = ImageRatioField('file', '430x360')#easy_thumbs for admin
> inline resizing
>
>
page_processors.py
@processor_for(Category)
> def category_page(request, page):
>
> listings =
> Listing.objects.prefetch_related('images').filter(categories=page)
>
> return {"listings": listings}
>
>
template
<ul>
{% for listing in listings %}
<li><a href="{{ listing.get_absolute_url }}">{{ listing.title }}</a></li>
{% with image=listing.images.all|first %}
<img alt="{{ image.description }}" src="{{ MEDIA_URL }}{% thumbnail
image.file 20 20 %}" />
{% endwith %}
{% endfor %}
</ul>
--
You received this message because you are subscribed to the Google Groups
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.