[mezzanine-users] Re: Thumbnail Tag with Prefetch Related Set Only Works on Last Image
Nevermind. I think all is working as expected. I just needed to clean up s3 after all the uploads during development. On Tuesday, July 11, 2017 at 12:27:37 PM UTC-7, Matt Mansour wrote: > > 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 > > > {% for listing in listings %} > {{ listing.title }} > > {% with image=listing.images.all|first %} > > {% endwith %} > > {% endfor %} > > > > -- 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 mezzanine-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [mezzanine-users] Thumbnail Tag with Prefetch Related Set Only Works on Last Image
Upon further digging it has nothing to do with pre-fetch related. It has to do with where I get my media from. All images in my object list are thumbnailed when I run media from my local server. However, if I run media from s3 only some images are thumbnailed. Has anyone run into this issue? On Tue, Jul 11, 2017 at 12:27 PM, Matt Mansourwrote: > 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 > > > {% for listing in listings %} > {{ listing.title }} > > {% with image=listing.images.all|first %} > > {% endwith %} > > {% endfor %} > > > > -- > 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 mezzanine-users+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- 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 mezzanine-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[mezzanine-users] Thumbnail Tag with Prefetch Related Set Only Works on Last Image
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 {% for listing in listings %} {{ listing.title }} {% with image=listing.images.all|first %} {% endwith %} {% endfor %} -- 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 mezzanine-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[mezzanine-users] How include a form in index.html?
Hello, sorry, i'm new in Mezzanine. I've made a form with dedicated route. But I wish to have the form also on the main page (index.html). -- 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 mezzanine-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
RE: [mezzanine-users] default settings for users / blog posts
The “is_staff” flag only allows users to log into the admin. Groups and permissions determine which models they can add/edit/delete. -- 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 mezzanine-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [mezzanine-users] default settings for users / blog posts
On Monday, July 10, 2017 at 11:48:18 PM UTC+3, Eduardo Rivas wrote: > > Hello Patrick. > > > >1. I don’t think there’s a setting to require a login for blog posts. >I suggest you override Mezzanine’s blog patterns in your root urlconf and >apply the login_required decorator to the blog views. See: >https://stackoverflow.com/a/5771286/1330003 >2. If you want to apply custom logic to the signup process you can go >with signals. Specifically the post_save signal on the User model. >https://docs.djangoproject.com/en/1.11/topics/signals/ > > For future reference I have this in my models.py file : +++ from django.db.models.signals import post_save from django.contrib.auth.models import User, Group from mezzanine.core.models import SitePermission def add_user_to_public_group(sender, instance, created, **kwargs): """Post-create user signal that adds the user to member group.""" try: if created: instance.groups.add(Group.objects.get(name='member')) sender.objects.filter(id=instance.id).update(is_staff='1') siteperms = SitePermission.objects.create(user=sender.objects.get(id=instance.id)) siteperms.sites.add(2) except Group.DoesNotExist: pass post_save.connect(add_user_to_public_group, sender=User) +++ I have created a group "member" with permissions to create/edit/delete blog posts. Is that necessary or does the "staff" value override those permissions? -- Patrick Shirkey Boost Hardware Ltd -- 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 mezzanine-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.