本文整理汇总了Python中models.Tag.attach_tags方法的典型用法代码示例。如果您正苦于以下问题:Python Tag.attach_tags方法的具体用法?Python Tag.attach_tags怎么用?Python Tag.attach_tags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Tag
的用法示例。
在下文中一共展示了Tag.attach_tags方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_post
# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import attach_tags [as 别名]
def get_post(self, post_id):
from models import Post, Tag, Subscribed
try:
posts = Post.objects.comments_count().filter(pk=post_id)
posts = Subscribed.join_is_subscribed(self.user, posts)
posts = Tag.attach_tags(posts)
post = posts[0]
except (Post.DoesNotExist, IndexError):
raise PostInterfaceError("Message not found.")
return post
示例2: paginate
# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import attach_tags [as 别名]
def paginate(queryset, numpage=1, per_page=20):
from models import Tag
paginate = Paginator(
queryset.select_related('user', 'user__profile'),
per_page
)
try:
page = paginate.page(numpage)
except (EmptyPage, InvalidPage):
page = paginate.page(paginate.num_pages)
posts = page.object_list
posts = Tag.attach_tags(posts)
return posts
示例3: select_related_tag
# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import attach_tags [as 别名]
def select_related_tag(self):
from models import Tag
return Tag.attach_tags(self)