我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用wagtail.wagtailcore.fields.StreamField()。
def get_page_blocks(page): blocks = [] for field in page.specific._meta.fields: if not isinstance(field, StreamField): continue for stream_child in getattr(page.specific, field.name): blocks.extend(get_field_blocks(stream_child)) return sorted(set(map(get_block_name, blocks)))
def test_body(self): field = CustomContent._meta.get_field('body') self.assertModelField(field, StreamField, True, True, None) # meta
def test_content(self): field = AbstractCard._meta.get_field('content') self.assertModelField(field, StreamField, False, False)
def test_content(self): field = AbstractSectionItem._meta.get_field('content') self.assertModelField(field, StreamField, True, True)
def test_left_content(self): field = TwoColumn._meta.get_field('left_content') self.assertModelField(field, StreamField, False, False, None)
def test_right_content(self): field = TwoColumn._meta.get_field('right_content') self.assertModelField(field, StreamField, False, False, None) # meta