Skip to content

Commit

Permalink
Upgrade for Wagtail 3/4 support.
Browse files Browse the repository at this point in the history
  • Loading branch information
FlipperPA committed Oct 20, 2022
1 parent e43002c commit 1d3ee65
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions wagtailcontentstream/models.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# Wagtail 2.0 compatibility - new package paths
try:
from wagtail.admin.edit_handlers import StreamFieldPanel
from wagtail import VERSION as WAGTAIL_VERSION


if WAGTAIL_VERSION >= (3, 0):
from wagtail.admin.panels import FieldPanel
from wagtail.fields import StreamField
from wagtail.models import Page
else:
from wagtail.admin.edit_handlers import StreamFieldPanel as FieldPanel
from wagtail.core.fields import StreamField
from wagtail.core.models import Page
except ImportError:
from wagtail.wagtailadmin.edit_handlers import StreamFieldPanel
from wagtail.wagtailcore.fields import StreamField
from wagtail.wagtailcore.models import Page

from .blocks import ContentStreamBlock, ContentStreamBlockWithRawCode, SectionBlock

Expand All @@ -18,7 +20,7 @@ class ContentStreamPage(Page):
)

content_panels = Page.content_panels + [
StreamFieldPanel("body"),
FieldPanel("body"),
]

class Meta:
Expand All @@ -32,7 +34,7 @@ class ContentStreamPageWithRawCode(Page):
)

content_panels = Page.content_panels + [
StreamFieldPanel("body"),
FieldPanel("body"),
]

class Meta:
Expand All @@ -46,7 +48,7 @@ class SectionContentStreamPage(Page):
)

content_panels = Page.content_panels + [
StreamFieldPanel("body"),
FieldPanel("body"),
]

class Meta:
Expand Down

0 comments on commit 1d3ee65

Please sign in to comment.