我使用wagtail cms制作我的博客。 所以我在django项目中安装了wagtail菜单。 我按照官方文档创建了一个顶级菜单,但它显示了我在wagtail admin中创建的单个项目。
Settings.py
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', # Don't repeat if it's there already
'wagtailmenus',
'modelcluster',
'taggit',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
中间件:
MIDDLEWARE = [
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
'wagtail.wagtailcore.middleware.SiteMiddleware',
'wagtail.wagtailredirects.middleware.RedirectMiddleware',
contextprocessors:
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'wagtail.contrib.settings.context_processors.settings',
'wagtailmenus.context_processors.wagtailmenus',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.template.context_processors.static',
'django.template.context_processors.tz',
],
我在base.html中包含此代码以包含mainmenu。
{% wagtailuserbar %}
{% load menu_tags %}
{% main_menu max_levels=3 show_multiple_levels=True apply_active_classes=True %}
然后我在管理员中创建了3个页面并尝试链接菜单。主菜单和平面菜单选项用于创建菜单。我使用主菜单并使用我创建的页面创建了一些菜单项但我只得到我创建的第一个主菜单。其他菜单项不可见。