From 17acb8867d51a10640fcbd6460e0ba8befcc1014 Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Fri, 13 Feb 2015 21:37:37 +0000 Subject: [PATCH] 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. --- wagtail/wagtailcore/fields.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/wagtail/wagtailcore/fields.py b/wagtail/wagtailcore/fields.py index 9de1ec81c..ede90dacd 100644 --- a/wagtail/wagtailcore/fields.py +++ b/wagtail/wagtailcore/fields.py @@ -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):