From 7f9fe866f311c93871c3620356b4816732941167 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 8 Dec 2016 11:15:05 +0000 Subject: [PATCH] Added stream field to all page models --- project/blog/models.py | 9 ++++----- project/pages/models.py | 7 ++++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/project/blog/models.py b/project/blog/models.py index 31912d2..cfbafa7 100644 --- a/project/blog/models.py +++ b/project/blog/models.py @@ -1,8 +1,7 @@ from django.db import models - +from project.common.fields import build_stream_field from wagtail.wagtailcore.models import Page -from wagtail.wagtailcore.fields import RichTextField -from wagtail.wagtailadmin.edit_handlers import FieldPanel +from wagtail.wagtailadmin.edit_handlers import FieldPanel, StreamFieldPanel from wagtail.wagtailimages.edit_handlers import ImageChooserPanel from wagtail.wagtailsearch import index @@ -19,7 +18,7 @@ class BlogPage(Entity): ) date = models.DateField("Post date") intro = models.CharField(max_length=250) - body = RichTextField(blank=True) + body = build_stream_field() search_fields = Page.search_fields + [ index.SearchField('intro'), @@ -30,5 +29,5 @@ class BlogPage(Entity): FieldPanel('date'), ImageChooserPanel('main_image'), FieldPanel('intro'), - FieldPanel('body'), + StreamFieldPanel('body'), ] diff --git a/project/pages/models.py b/project/pages/models.py index 6f851a6..8d89e6c 100644 --- a/project/pages/models.py +++ b/project/pages/models.py @@ -1,15 +1,16 @@ from django.db import models +from project.common.fields import build_stream_field from project.common.models import Entity from wagtail.wagtailcore.models import Page from wagtail.wagtailcore.fields import RichTextField -from wagtail.wagtailadmin.edit_handlers import FieldPanel +from wagtail.wagtailadmin.edit_handlers import FieldPanel, StreamFieldPanel class SimpleContentPage(Entity): - body = RichTextField() + body = build_stream_field() content_panels = Page.content_panels + [ - FieldPanel('body', classname="full") + StreamFieldPanel('body') ]