【发布时间】:2021-01-13 08:52:01
【问题描述】:
我认为ChildPage.objects.child_of(self) 和ParentPage.get_children() 产生相同的结果,因为ParentPage 的subpage_types 只是['ChildPage'] 之一。
但是当我尝试过滤ParentPage.get_children()的结果时出现错误。
def get_context(self, request, *args, **kwargs):
context = super().get_context(request, *args, **kwargs)
child = self.get_children().live().public() # <- don't works
child = ChildPage.objects.child_of(self).live().public() # <- works
if request.GET.get('tag', None):
tags = request.GET.get('tag')
child = child.filter(tags__slug__in=[tags]) # <- error here
context["child"] = child
return context
回溯(最近一次调用最后一次):
Cannot resolve keyword 'tags' into field. Choices are: alias_of, alias_of_id, aliases, blogindexpage, blogpage, content_type, content_type_id, depth, draft_title, expire_at, expired, first_published_at, formsubmission, go_live_at, group_permissions, has_unpublished_changes, homepage, id, last_published_at, latest_revision_created_at, live, live_revision, live_revision_id, locale, locale_id, locked, locked_at, locked_by, locked_by_id, numchild, owner, owner_id, partnerindexpage, partnerpage, path, redirect, revisions, search_description, seo_title, show_in_menus, sites_rooted_here, slug, title, translation_key, url_path, view_restrictions, workflow_states, workflowpage
【问题讨论】:
标签: wagtail django-taggit