最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

django - i have a problem with the importation of wagtail.contrib.settings.models import ModelSettings - Stack Overflow

programmeradmin0浏览0评论
from django.db import models

from wagtail.admin.panels import FieldPanel, MultiFieldPanel
from wagtail.contrib.settings.models import ModelSettings,register_setting

@register_setting
class SocialMediaSettings(ModelSettings):
    """Social media settings for our custom website."""

    facebook = models.URLField(blank=True, null=True, help_text="Facebook URL")
    twitter = models.URLField(blank=True, null=True, help_text="Twitter URL")
    youtube = models.URLField(blank=True, null=True, help_text="YouTube Channel URL")

    panels = [
        MultiFieldPanel([
            FieldPanel("facebook"),
            FieldPanel("twitter"),
            FieldPanel("youtube"),
        ], heading="Social Media Settings")
    ]

I have already upgraded to the latest version of Wagtail but still encounter the error ImportError: cannot import name 'ModelSettings' from 'wagtail.contrib.settings.models

from django.db import models

from wagtail.admin.panels import FieldPanel, MultiFieldPanel
from wagtail.contrib.settings.models import ModelSettings,register_setting

@register_setting
class SocialMediaSettings(ModelSettings):
    """Social media settings for our custom website."""

    facebook = models.URLField(blank=True, null=True, help_text="Facebook URL")
    twitter = models.URLField(blank=True, null=True, help_text="Twitter URL")
    youtube = models.URLField(blank=True, null=True, help_text="YouTube Channel URL")

    panels = [
        MultiFieldPanel([
            FieldPanel("facebook"),
            FieldPanel("twitter"),
            FieldPanel("youtube"),
        ], heading="Social Media Settings")
    ]

I have already upgraded to the latest version of Wagtail but still encounter the error ImportError: cannot import name 'ModelSettings' from 'wagtail.contrib.settings.models

Share Improve this question edited Jan 19 at 15:51 gasman 25.2k2 gold badges46 silver badges59 bronze badges asked Jan 19 at 14:56 msafiri mchomvumsafiri mchomvu 132 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Wagtail does not provide a class named ModelSettings. As per the documentation for the wagtail.contrib.setting module, the two available base classes in wagtail.contrib.settings.models are:

  • BaseGenericSetting for generic settings across all sites
  • BaseSiteSetting for site-specific settings

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论