คุณช่วยฉันด้วยปัญหานี้ได้ไหม ฉันกำลังพยายามเพิ่มแสดงเฉพาะชื่อเมนูที่แปลเท่านั้น และเพิ่มโค้ดนี้ลงในไฟล์แท็กของฉัน:
@register.inclusion_tag('home/tags/top_menu.html', takes_context=True)
def top_menu(context, parent, calling_page=None):
request = context['request']
language_code = request.LANGUAGE_CODE
menuitems = parent.get_children().live().in_menu().filter(title = language_code)[0].get_children()
for menuitem in menuitems:
menuitem.show_dropdown = has_menu_children(menuitem)
menuitem.active = (calling_page.path.startswith(menuitem.path)
if calling_page else False)
return {
'calling_page': calling_page,
'menuitems': menuitems,
'request': context['request'],
}
แต่ฉันได้รับข้อผิดพลาดนี้ในหน้า : รายการดัชนีอยู่นอกช่วงและโค้ดที่เน้นสี
{% top_menu parent=site_root โทร_เพจ=ตนเอง %}
ใช้ Wagtail 1.12 และ Python 3.6.2