本文整理汇总了Python中models.Folder.userChoices方法的典型用法代码示例。如果您正苦于以下问题:Python Folder.userChoices方法的具体用法?Python Folder.userChoices怎么用?Python Folder.userChoices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Folder
的用法示例。
在下文中一共展示了Folder.userChoices方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: hash_tags
# 需要导入模块: from models import Folder [as 别名]
# 或者: from models.Folder import userChoices [as 别名]
def hash_tags(request):
# putting an .exclude(notes__folder__name = 'Trash') will exclude
# a tag that has *any* tagged note in Trash. We want to
# check for *all* !! Hence the for loop.
choices = Folder.userChoices(request.user)
if 'folder' in request.POST:
folder = Folder.objects.get(user = request.user, pk=request.POST['folder'])
else:
folder = Folder.objects.get(user = request.user, name = "Main")
my_hash_tags = HashTags.objects.filter(user=request.user).order_by('hash_tag', 'notes__folder__name').distinct()
tag_list = []
for tag in my_hash_tags:
if tag.notes.filter(folder = folder).count() > 0:
if tag not in tag_list: tag_list.append(tag)
context = {'tags':tag_list, 'choices':choices, 'selected':folder}
return render(request, 'cloud_notes/hash_tags.html', context)