Blog body is a stream field
This commit is contained in:
parent
dbd449b708
commit
f96124b744
9 changed files with 54 additions and 5 deletions
17
.idea/dataSources.xml
generated
Normal file
17
.idea/dataSources.xml
generated
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||
<data-source source="LOCAL" name="db" uuid="0f87778f-defe-4695-a936-54cb7c13118a">
|
||||
<driver-ref>sqlite.xerial</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<jdbc-driver>org.sqlite.JDBC</jdbc-driver>
|
||||
<jdbc-url>jdbc:sqlite:$PROJECT_DIR$/db.sqlite3</jdbc-url>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
<libraries>
|
||||
<library>
|
||||
<url>file://$APPLICATION_CONFIG_DIR$/jdbc-drivers/Xerial SQLiteJDBC/3.43.0/org/xerial/sqlite-jdbc/3.43.0.0/sqlite-jdbc-3.43.0.0.jar</url>
|
||||
</library>
|
||||
</libraries>
|
||||
</data-source>
|
||||
</component>
|
||||
</project>
|
5
blog/blocks.py
Normal file
5
blog/blocks.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
from wagtail.blocks import RichTextBlock
|
||||
|
||||
from base.blocks import StreamBlock
|
||||
class BlogPostBlock(StreamBlock):
|
||||
paragraph = RichTextBlock(blank=True)
|
20
blog/migrations/0008_alter_blogpage_body.py
Normal file
20
blog/migrations/0008_alter_blogpage_body.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
# Generated by Django 5.0.2 on 2024-03-14 02:46
|
||||
|
||||
import wagtail.blocks
|
||||
import wagtail.fields
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('blog', '0007_blogtagindexpage'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='blogpage',
|
||||
name='body',
|
||||
field=wagtail.fields.StreamField([('paragraph', wagtail.blocks.RichTextBlock(blank=True))], blank=True, help_text='Write anything'),
|
||||
),
|
||||
]
|
|
@ -5,12 +5,15 @@ from modelcluster.contrib.taggit import ClusterTaggableManager
|
|||
from taggit.models import TaggedItemBase
|
||||
|
||||
from wagtail.models import Page, Orderable
|
||||
from wagtail.fields import RichTextField
|
||||
from wagtail.fields import RichTextField, StreamField
|
||||
from wagtail.admin.panels import FieldPanel, InlinePanel, MultiFieldPanel
|
||||
from wagtail.search import index
|
||||
|
||||
from wagtail.snippets.models import register_snippet
|
||||
|
||||
from blog.blocks import BlogPostBlock
|
||||
|
||||
|
||||
class BlogIndexPage(Page):
|
||||
intro = RichTextField(blank=True)
|
||||
|
||||
|
@ -46,7 +49,12 @@ class BlogPageTag(TaggedItemBase):
|
|||
class BlogPage(Page):
|
||||
date = models.DateField("Post date")
|
||||
intro = models.CharField(max_length=250)
|
||||
body = RichTextField(blank=True)
|
||||
body = StreamField(
|
||||
BlogPostBlock(),
|
||||
blank=True,
|
||||
use_json_field=True,
|
||||
help_text="Write anything",
|
||||
)
|
||||
|
||||
authors = ParentalManyToManyField('blog.Author', blank=True)
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
{% endwith %}
|
||||
|
||||
<p>{{ post.intro }}</p>
|
||||
{{ post.body|richtext }}
|
||||
{{ post.body }}
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
<div class="intro">{{ page.intro }}</div>
|
||||
|
||||
{{ page.body|richtext }}
|
||||
{{ page.body }}
|
||||
|
||||
{% for item in page.gallery_images.all %}
|
||||
<div style="float: inline-start; margin: 10px">
|
||||
|
|
BIN
media/images/pexels-life-of-pix-8892.max-800x600.jpg
Normal file
BIN
media/images/pexels-life-of-pix-8892.max-800x600.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 89 KiB |
BIN
media/images/pexels-life-of-pix-8892.width-800.jpg
Normal file
BIN
media/images/pexels-life-of-pix-8892.width-800.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 89 KiB |
|
@ -7,7 +7,6 @@ from wagtail.blocks import (
|
|||
StructBlock,
|
||||
)
|
||||
|
||||
# import ImageChooserBlock:
|
||||
from wagtail.images.blocks import ImageChooserBlock
|
||||
|
||||
from base.blocks import BaseStreamBlock
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue