kopia lustrzana https://github.com/wagtail/wagtail
				
				
				
			
							rodzic
							
								
									23a8fe8e0e
								
							
						
					
					
						commit
						2ca09bdc37
					
				|  | @ -6,6 +6,7 @@ Changelog | |||
| 
 | ||||
|  * Fix: Prevent choosers from failing when initial value is an unrecognised ID, e.g. when moving a page from a location where `parent_page_types` would disallow it (Dan Braghis) | ||||
|  * Docs: Document how to add non-ModelAdmin views to a `ModelAdminGroup` (Onno Timmerman) | ||||
|  * Docs: Document how to add StructBlock data to a StreamField (Ramon Wenger) | ||||
|  * Maintenance: Switch to ruff for flake8 / isort code checking (Oliver Parker) | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -708,6 +708,7 @@ Contributors | |||
| * Steve Steinwand | ||||
| * Swojak-A | ||||
| * fidoriel | ||||
| * Ramon Wenger | ||||
| 
 | ||||
| Translators | ||||
| =========== | ||||
|  |  | |||
|  | @ -24,6 +24,7 @@ depth: 1 | |||
| ### Documentation | ||||
| 
 | ||||
|  * Document how to add non-ModelAdmin views to a `ModelAdminGroup` (Onno Timmerman) | ||||
|  * Document how to add StructBlock data to a StreamField (Ramon Wenger) | ||||
| 
 | ||||
| ### Maintenance | ||||
| 
 | ||||
|  |  | |||
|  | @ -519,6 +519,29 @@ my_page.body.append(('paragraph', RichText("<p>And they all lived happily ever a | |||
| my_page.save() | ||||
| ``` | ||||
| 
 | ||||
| If a block extending a StructBlock is to be used inside of the StreamField's value, the value of this block can be provided as a python dict (similar in what is accepted by the block's `.to_python` method). | ||||
| 
 | ||||
| ```python | ||||
| 
 | ||||
| from wagtail import blocks | ||||
| 
 | ||||
| class UrlWithTextBlock(blocks.StructBlock): | ||||
|    url = blocks.URLBlock() | ||||
|    text = blocks.TextBlock() | ||||
| 
 | ||||
| # using this block inside the content | ||||
| 
 | ||||
| data = { | ||||
|     'url': 'https://github.com/wagtail/', | ||||
|     'text': 'A very interesting and useful repo' | ||||
| } | ||||
| 
 | ||||
| # append the new block to the stream as a tuple with the defined index for this block type | ||||
| my_page.body.append(('url', data)) | ||||
| my_page.save() | ||||
| 
 | ||||
| ``` | ||||
| 
 | ||||
| (streamfield_retrieving_blocks_by_name)= | ||||
| 
 | ||||
| ## Retrieving blocks by name | ||||
|  |  | |||
		Ładowanie…
	
		Reference in New Issue
	
	 Ramon Wenger
						Ramon Wenger