1
Fork 0

Added stream field to all page models

This commit is contained in:
Jake Howard 2016-12-08 11:15:05 +00:00
parent 0c4b6432d6
commit 7f9fe866f3
2 changed files with 8 additions and 8 deletions

View file

@ -1,8 +1,7 @@
from django.db import models from django.db import models
from project.common.fields import build_stream_field
from wagtail.wagtailcore.models import Page from wagtail.wagtailcore.models import Page
from wagtail.wagtailcore.fields import RichTextField from wagtail.wagtailadmin.edit_handlers import FieldPanel, StreamFieldPanel
from wagtail.wagtailadmin.edit_handlers import FieldPanel
from wagtail.wagtailimages.edit_handlers import ImageChooserPanel from wagtail.wagtailimages.edit_handlers import ImageChooserPanel
from wagtail.wagtailsearch import index from wagtail.wagtailsearch import index
@ -19,7 +18,7 @@ class BlogPage(Entity):
) )
date = models.DateField("Post date") date = models.DateField("Post date")
intro = models.CharField(max_length=250) intro = models.CharField(max_length=250)
body = RichTextField(blank=True) body = build_stream_field()
search_fields = Page.search_fields + [ search_fields = Page.search_fields + [
index.SearchField('intro'), index.SearchField('intro'),
@ -30,5 +29,5 @@ class BlogPage(Entity):
FieldPanel('date'), FieldPanel('date'),
ImageChooserPanel('main_image'), ImageChooserPanel('main_image'),
FieldPanel('intro'), FieldPanel('intro'),
FieldPanel('body'), StreamFieldPanel('body'),
] ]

View file

@ -1,15 +1,16 @@
from django.db import models from django.db import models
from project.common.fields import build_stream_field
from project.common.models import Entity from project.common.models import Entity
from wagtail.wagtailcore.models import Page from wagtail.wagtailcore.models import Page
from wagtail.wagtailcore.fields import RichTextField from wagtail.wagtailcore.fields import RichTextField
from wagtail.wagtailadmin.edit_handlers import FieldPanel from wagtail.wagtailadmin.edit_handlers import FieldPanel, StreamFieldPanel
class SimpleContentPage(Entity): class SimpleContentPage(Entity):
body = RichTextField() body = build_stream_field()
content_panels = Page.content_panels + [ content_panels = Page.content_panels + [
FieldPanel('body', classname="full") StreamFieldPanel('body')
] ]