Django Wagtail Menus仅显示单个菜单项问题求助
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 menuscheckbox 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_menuoutput. To fix this, you can either:- Reparent the pages under Home in the Wagtail admin, or
- Adjust the
main_menutag 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_menutemplate—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

