Python wagtail Structural Block














































Python wagtail Structural Block



 
In the previous article we have discuss about Basic Blocks.If you have not gone through it you see through this link Basic Block.


In addition to the basic block types , it is possible to define new block types made up of sub-blocks: for example, a 'person' block consisting of sub-blocks for first name, surname and image, or a 'carousel' block consisting of an unlimited number of image blocks this new type of block are known as structural block.

  Following are the list of block structural list 
 

    StructBlock  ( wagtail.core.blocks.StructBlock)

A block consisting of a fixed group of sub-blocks to be displayed together. Takes a list of tuples as its first argument.

('person', blocks.StructBlock([
('first_name', blocks.CharBlock()),
('surname', blocks.CharBlock()),
('photo', ImageChooserBlock(required=False)),
('biography', blocks.RichTextBlock()),
], icon='user'))

   ListBlock  (wagtail.core.blocks.ListBlock)

A block consisting of many sub-blocks, all of the same type. The editor can add an unlimited number of sub-blocks, and re-order and delete them.

('ingredients_list', blocks.ListBlock(blocks.CharBlock(label="Ingredient")))

   StreamBlock (wagtail.core.blocks.StreamBlock)


A block consisting of a sequence of sub-blocks of different types, which can be mixed and reordered.

('carousel', blocks.StreamBlock(
[
('image', ImageChooserBlock()),
('quotation', blocks.StructBlock([
('text', blocks.TextBlock()),
('author', blocks.CharBlock()),
])),
('video', EmbedBlock()),
],
icon='cogs'
))

As with StructBlock, the list of sub-blocks can also be provided as a subclass of StreamBlock.

class CarouselBlock(blocks.StreamBlock):
image = ImageChooserBlock()
quotation = blocks.StructBlock([
('text', blocks.TextBlock()),
('author', blocks.CharBlock()),
])
video = EmbedBlock()

class Meta:
icon='cogs'
 StreamBlock accepts the following options as either keyword arguments 
  • required
  • min_num
  • max_num
  • block_counts

More Articles of SAYENDEEP MAHANTY:

Name Views Likes
C++ Exception Handling-|| 85 3
C++ Exception Handling 116 3
C++ File Handling EOF 93 5
C++ File Handling Error Handling During file Operation 1135 5
C++ File Handling seekp() Function 105 5
C++ File Handling seekg() Function 105 6
C++ File Handling tellg() Function 126 5
C++ File Handling tellp() Function 133 5
C++ File Handling close() Function 78 5
C++ File Handling:: open() 106 5
C++ File Handling Introduction 131 5
C++ Container Library:: std ::array-II 101 4
Top Django Interview Questions and Answers You Need to Know 302 6
C++ Container Library::std::array 96 6
C++ Container Library Introduction 103 5
Essential Engineering Skills for Your Resume 127 5
Mistakes To Avoid During Technical Interview 133 5
Mistakes You Must Avoid During Work From Home 178 6
Seven Common Mistakes that Beginners Should Avoid While Learning to Code 109 6
Simple Linear Regression 96 6
Python wagtailmenus 122 6
Python wagtail application 119 6
Python guppy GSL 136 5
Python wagtail guppy subpackage heapy 174 6
Python guppy Introduction 215 6
Python wagtail Structural Block 258 6
Python wagtail Integrating into Django Project 370 6
Python wagtail testing 280 7
Python wagtail Basic Block 349 7
Python wagtail image tag 216 7
Python wagtail Templates 179 6
Python wagtail Backends 206 6
Python wagtail Indexing 189 6
Python wagtail Search 173 7
Python wagtail Snippets 192 6
Python wagtail Writing your own page models 165 9
Python wagtail model class PageRevision 196 10
Python wagtail model class Site 198 9
Python wagtail wagtail core model 218 9
Python wagtail page models 189 10
Python wagtail 166 11

Comments