I am new to Wagtail and want to create several Field's in my models.py by iterating over a list of names like this ...
class HomePage(Page):
myFields = [ ('paragraph', blocks.RichTextBlock(classname="oneA")),('image', ImageChooserBlock()) ]
mySections = ['sectionOne', 'sectionTwo', 'sectionThree']
for mySection in mySections:
mySection = StreamField(myFields,null=True,blank=True)
content_panels = Page.content_panels + [
StreamFieldPanel('sectionOne'), StreamFieldPanel('sectionTwo'), StreamFieldPanel('sectionThree'),
]
This produces an error message ...
django.core.exceptions.FieldDoesNotExist: HomePage has no field named 'sectionOne'
Is there a way of doing this, or do I have to declare each one individually like so:
sectionOne = StreamField(myFields,null=True,blank=True)