pythondjangowagtaildjango-cms

Wagtail, can't add settings


I'm trying to add custom settings to wagtail (version 4.0.4).

Following the guide from the docs, I added wagtail.contrib.settings to INSTALLED_APPS and added this to models.py:

from wagtail.contrib.settings.models import register_setting, BaseGenericSetting
from django.db import models


@register_setting
class Authors(BaseGenericSetting):
    facebook = models.URLField()

Then made makemigrations/migrate. But nothing appeared in Wagtail settings.

Then I tried to register model in admin. In wagtail_admin.py

from wagtail.contrib.modeladmin.options import (
    ModelAdmin,
    modeladmin_register,
)
from .models import Authors


@modeladmin_register
class AuthorsAdmin(ModelAdmin):
    model = Authors
    list_display = ("facebook",)
    add_to_settings_menu = True
    menu_label = "Authors"

But still the same result. What do I miss? Some extra config or ...?

Only after removing add_to_settings_menu = True, Authors appears in the side-menu (but, of course, not in the settings). With this line - nothing.


Solution

  • Found the root problem. In my project, there was a custom

    @hooks.register("construct_settings_menu")
    def hide_settings_items(request, menu_items):
        menu_items[:] = [some_logic]
    

    Which deleted items from settings menu

    But I still have to do @modeladmin_register