You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Django Wagtail Menus仅显示单个菜单项问题求助

Troubleshooting: Only the First Home Menu Item Shows in Wagtailmenus

Hey, I’ve run into this exact issue before with wagtailmenus—let’s walk through the most common fixes step by step:

1. Double-check Page Publish Status & "Show in Menus" Setting

This is the most frequent culprit! For any page to appear in your menu:

  • Make sure the page is published (not just saved as a draft) — look for the green "Published" badge in the Wagtail admin.
  • Go to the page’s Promote tab, and ensure the Show in menus checkbox is ticked. It’s easy to miss this when creating pages!

2. Verify Page Hierarchy & Site Association

Wagtailmenus pulls menu items based on your site’s page structure by default:

  • If your non-Home pages are not direct children of the Home page, they won’t show up in the default main_menu output. To fix this, you can either:
    • Reparent the pages under Home in the Wagtail admin, or
    • Adjust the main_menu tag to use your site’s root page instead:
      {% main_menu root_page=site.root_page max_levels=3 show_multiple_levels=True apply_active_classes=True %}
      
  • Also confirm all menu pages belong to your current active site (check under Settings > Sites in the admin to verify your site’s root page).

3. Fix INSTALLED_APPS Order

Your current INSTALLED_APPS has wagtailmenus listed before modelcluster and taggit—this can cause dependency issues. Reorder them so wagtailmenus comes after those two:

INSTALLED_APPS = [
    'bootstrap3', 'blog', 'home', 'search', 
    'wagtail.wagtailforms', 'wagtail.wagtailredirects', 'wagtail.wagtailembeds', 
    'wagtail.wagtailsites', 'wagtail.wagtailusers', 'wagtail.wagtailsnippets', 
    'wagtail.wagtaildocs', 'wagtail.wagtailimages', 'wagtail.wagtailsearch', 
    'wagtail.wagtailadmin', 'wagtail.wagtailcore', 'wagtail.contrib.modeladmin', 
    'modelcluster', 'taggit',  # These come first
    'wagtailmenus',  # Now place wagtailmenus here
    'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 
    'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles',
]

4. Clear Caches

Sometimes stale cache can prevent new menu items from showing up:

  • Clear your browser cache (Ctrl+Shift+R on most browsers)
  • If you’re using Django’s caching backend, run this command to clear server-side cache:
    python manage.py clear_cache
    

5. Debug Menu Output Directly

To narrow down if the issue is with menu retrieval or template rendering, add this debug code to your base.html:

{% load menu_tags %}
{% get_menu 'main' as main_menu %}
<div style="background: #eee; padding: 10px;">
  Debug Menu Items:
  {% for item in main_menu.menu_items %}
    <p>{{ item.text }} | URL: {{ item.href }}</p>
  {% empty %}
    <p>No menu items found!</p>
  {% endfor %}
</div>
  • If this shows all your menu items, the problem is with the default main_menu template—you might need to customize the menu template to match your needs.
  • If it only shows the Home item, then the menu isn’t being populated correctly, go back to steps 1-3.

6. Check Custom Menu Configuration (If Applicable)

If you created a custom "Main Menu" in the Wagtail admin (instead of using the page hierarchy):

  • Go to Settings > Menus > Main Menu and confirm all your menu items are added and saved.
  • Ensure each menu item is linked to a published page.

内容的提问来源于stack exchange,提问作者Kme

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 06:46:53