Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_by_path(self, blog_path):
# Look for the blog checking all the path
from .models import BlogPage
blogs = BlogPage.objects.filter(slug=blog_path.split("/")[-1])
for blog in blogs:
if strip_prefix_and_ending_slash(blog.specific.last_url_part) == blog_path:
return blog.specific
return
def newsfeed(self):
# Get list of latest news
curlang = translation.get_language()
parent = BlogPage.objects.filter(slug='news-%s' % curlang)
if not parent: return []
entries = EntryPage.objects.live().descendant_of(parent[0])
# Order by most recent date first
entries = entries.order_by('-date')
return entries[:4]