1
Fork 0

Add blog model

This commit is contained in:
Jake Howard 2018-07-26 08:44:14 +01:00
parent ef6b0496eb
commit 32d93b31ce
Signed by: jake
GPG key ID: 57AFB45680EDD477
5 changed files with 56 additions and 0 deletions

0
project/blog/__init__.py Normal file
View file

View file

@ -0,0 +1,39 @@
# Generated by Django 2.0.7 on 2018-07-26 07:38
from django.db import migrations, models
import django.db.models.deletion
import wagtail.core.blocks
import wagtail.core.fields
import wagtail.documents.blocks
import wagtail.embeds.blocks
import wagtail.images.blocks
import wagtailmarkdown.blocks
import wagtailmetadata.models
class Migration(migrations.Migration):
initial = True
dependencies = [
('wagtailcore', '0040_page_draft_title'),
('wagtailimages', '0020_add-verbose-name'),
]
operations = [
migrations.CreateModel(
name='BlogPage',
fields=[
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
('created', models.DateTimeField(auto_now_add=True)),
('modified', models.DateTimeField(auto_now=True)),
('post_date', models.DateTimeField(blank=True, null=True)),
('body', wagtail.core.fields.StreamField([('document', wagtail.documents.blocks.DocumentChooserBlock()), ('heading', wagtail.core.blocks.StructBlock([('size', wagtail.core.blocks.ChoiceBlock(choices=[('h1', 'H1'), ('h2', 'H2'), ('h3', 'H3'), ('h4', 'H4'), ('h5', 'H5')])), ('value', wagtail.core.blocks.CharBlock())])), ('image', wagtail.images.blocks.ImageChooserBlock()), ('markdown', wagtailmarkdown.blocks.MarkdownBlock()), ('ol', wagtail.core.blocks.ListBlock(wagtail.core.blocks.CharBlock(label='List Item'), icon='list-ol', label='Ordered List', template='blocks/ordered-list.html')), ('paragraph', wagtail.core.blocks.RichTextBlock()), ('raw_html', wagtail.core.blocks.RawHTMLBlock(label='Raw HTML')), ('ul', wagtail.core.blocks.ListBlock(wagtail.core.blocks.CharBlock(label='List Item'), icon='list-ul', label='Unordered List')), ('video', wagtail.core.blocks.StructBlock([('video', wagtail.embeds.blocks.EmbedBlock()), ('caption', wagtail.core.blocks.CharBlock())]))])),
('search_image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.Image')),
],
options={
'abstract': False,
},
bases=(wagtailmetadata.models.MetadataMixin, 'wagtailcore.page', models.Model),
),
]

View file

16
project/blog/models.py Normal file
View file

@ -0,0 +1,16 @@
from project.common.blocks import build_stream_field
from wagtail.admin.edit_handlers import StreamFieldPanel
from wagtail.search import index
from project.common.models import Entity
class BlogPage(Entity):
body = build_stream_field()
search_fields = Entity.search_fields + [
index.SearchField('body'),
]
content_panels = Entity.content_panels + [
StreamFieldPanel('body'),
]

View file

@ -45,6 +45,7 @@ INSTALLED_APPS = [
'project.search', 'project.search',
'project.common', 'project.common',
'project.pages', 'project.pages',
'project.blog',
'wagtail.contrib.forms', 'wagtail.contrib.forms',
'wagtail.contrib.redirects', 'wagtail.contrib.redirects',