Browse Source

Simplify list comprehensions when getting all tags for children of BlogPage

Scot Hacker 8 years ago
parent
commit
92df81d8a2
1 changed files with 5 additions and 3 deletions
  1. 5 3
      bakerydemo/blog/models.py

+ 5 - 3
bakerydemo/blog/models.py

@@ -159,9 +159,11 @@ class BlogIndexPage(BasePageFieldsMixin, RoutablePageMixin, Page):
 
     def get_child_tags(self):
         """
-        Returns the list of Tags for child pages.
+        Returns the list of Tags for all child posts of this BlogPage.
         """
-        tags = [x.get_tags for x in self.get_posts()]
-        tags = [item for sublist in tags for item in sublist]
+
+        tags = []
+        for post in self.get_posts():
+            tags += post.get_tags  # Not tags.append() because we don't want a list of lists
         tags = sorted(set(tags))
         return tags