msafiri mchomvu
msafiri mchomvu

Reputation: 13

i have a problem with the importation of wagtail.contrib.settings.models import ModelSettings

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

Upvotes: 0

Views: 26

Answers (1)

gasman
gasman

Reputation: 25227

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

Upvotes: 0

Related Questions