Wagtail内容流提供了一个标准内容类型的StreamField。
项目描述
Wagtail内容流
一个抽象的Django模型,包含一个名为body
的Wagtail StreamField,包含我在日常使用中常用的多个块。这是针对需要编写包含代码示例的开发者设计的。它具有明确的观点:文本块中允许的HTML非常少,迫使作者创建结构化数据。以下块包含在ContentStreamBlock
中
- 标题
- 段落
- 带标题的图片
- 嵌入
- 表格
- 代码块
一个二级StreamBlock,ContentStreamBlockWithRawCode
,还提供了一个用于注入HTML、JS和CSS代码的附加块。请谨慎使用,因为这可能会让你的标记膨胀,并且可能成为代码注入的潜在点!
提供了三种页面类型。
示例用法
您需要将 wagtailcodeblock
添加到您的 Django 设置 INSTALLED_APPS
中。
基本用法:标题字段和内容流
首先,在您的 models.py
中创建一个页面类型
from wagtailcontentstream.models import ContentStreamPage, SectionContentStreamPage, ContentStreamPageWithRawCode
class StandardPage(ContentStreamPage):
pass
class SectionStandardPage(SectionContentStreamPage):
pass
class StandardPageWithRawCode(ContentStreamPageWithRawCode):
pass
然后在您的模板中
{% load wagtailcore_tags %}
<h2>{{ page.title }}</h2>
{% include_block page.body %}
扩展用法:添加更多字段
from django.conf import settings
from django.db import models
from wagtail.admin.edit_handlers import FieldPanel
from wagtailcontentstream.models import ContentStreamPage
class StandardPage(ContentStreamPage):
date = models.DateField("Post Date")
authors = models.ManyToManyField(settings.AUTH_USER_MODEL)
content_panels = [
FieldPanel('date'),
FieldPanel('authors'),
] + ContentStreamPage.content_panels
发行说明 & 贡献者
项目负责人
- Timothy Allen (https://github.com/FlipperPA)
项目详情
下载文件
为您的平台下载文件。如果您不确定选择哪一个,请了解更多关于安装包的信息。
源代码分发
wagtailcontentstream-1.0.0.tar.gz (7.4 kB 查看哈希)
构建分发
关闭
wagtailcontentstream-1.0.0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 460ef53b00dd7273c821dc848cecf00af71473f86d36ec3a87bc1e2351fc5fa1 |
|
MD5 | a5b5ca4d858da6d7640152f5bf72e14f |
|
BLAKE2b-256 | 21a9caaf3a4c0f15586533e14f1bf851dd907865a2d24c5e4b3e63b9df2f9aa5 |
关闭
wagtailcontentstream-1.0.0-py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 681449e95f86bde99cd1786d289174a746311b2f4176b8b03e72bb65b9d83b1b |
|
MD5 | 648cf30429916b99a5628bb12fdb2e5d |
|
BLAKE2b-256 | 77f9104b4fd90ffd76ddc063c7c77876a95033ce8334d8dfa64f321e2db5edc3 |