mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-12 09:13:14 +00:00
Normalise the output of StreamField.deconstruct to a list of block defs.
This ensures that the migration code is the same even if the StreamBlock is defined as an external instance or class, and that in those cases the block definitions get frozen into the migration.
This commit is contained in:
parent
0ee9649415
commit
17acb8867d
1 changed files with 3 additions and 4 deletions
|
|
@ -42,8 +42,6 @@ class RichTextField(models.TextField):
|
|||
|
||||
class StreamField(with_metaclass(models.SubfieldBase, models.Field)):
|
||||
def __init__(self, block_types, **kwargs):
|
||||
self.block_types = block_types
|
||||
|
||||
if isinstance(block_types, Block):
|
||||
self.stream_block = block_types
|
||||
elif isinstance(block_types, type):
|
||||
|
|
@ -56,8 +54,9 @@ class StreamField(with_metaclass(models.SubfieldBase, models.Field)):
|
|||
return 'TextField'
|
||||
|
||||
def deconstruct(self):
|
||||
name, path, args, kwargs = super(StreamField, self).deconstruct()
|
||||
kwargs['block_types'] = self.block_types
|
||||
name, path, _, kwargs = super(StreamField, self).deconstruct()
|
||||
block_types = self.stream_block.child_blocks.items()
|
||||
args = [block_types]
|
||||
return name, path, args, kwargs
|
||||
|
||||
def to_python(self, value):
|
||||
|
|
|
|||
Loading…
Reference in a new issue