I'm creating portfolio app. And on the inner page I'd like to give a link to the next portfolio record with it's thumbnail.
Wagtail: Get previous or next sibling — Here is an answer on how to get the url. But it doesn't work for getting other attributes.
If i change 'url' in this method:
def next_portfolio(self):
if self.get_next_sibling():
return self.get_next_sibling().url
else:
return self.get_siblings().first().url
To get not '.url' but '.thumbnail'
def next_portfolio(self):
if self.get_next_sibling():
return self.get_next_sibling().thumbnail
else:
return self.get_siblings().first().thumbnail
All I get is an error "'Page' object has no attribute 'thumbnail'". but it have. That's how my model looks like:
class PortfolioItem(Page):
thumbnail = models.ImageField(upload_to = '', default = None)
is_feautered = models.BooleanField(default=False)
def next_portfolio_thumb(self):
if self.get_next_sibling():
return self.get_next_sibling().thumbnail
else:
return self.get_siblings().first()
It should be obvious way to get sibling attribute. Could you please point me on how to do it?