Open johncarter-phntm opened 2 years ago
Hi @johncarter-phntm , could you give an example of how you would use this?
Potentially related: https://github.com/wagtail/wagtail-factories/issues/57
Hi, my use case is I want some blocks to be generated by the subfactory by default.
eg:
class MyBlockFactory(wagtail_factories.StructBlockFactory):
items = wagtail_factories.ListBlockFactory(MyBlockItemFactory, size=3)
class Meta:
model = models.MyBlock
Also having support for lambda like RelatedFactoryList might be nice:
class MyBlockFactory(wagtail_factories.StructBlockFactory):
items = wagtail_factories.ListBlockFactory(MyBlockItemFactory, size=lambda: random.randint(1, 5))
class Meta:
model = models.MyBlock
I'm thinking if individual elements were specified with items__0
etc this would still fill in up to size
elements.
It'd be really handy to have ListBlockFactory generate a list of N blocks, like RelatedFactoryList does, I think that's currently not possible unless we pass parameters to those sub-blocks.