소스 검색

Simplify list comprehensions when getting all tags for children of BlogPage

Scot Hacker 8 년 전
부모
커밋
92df81d8a2
1개의 변경된 파일5개의 추가작업 그리고 3개의 파일을 삭제
  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