Yes , you can definitely add Streamfield to the fragment. It works just as if you used it in a subclass of Wagtail Page. Here's a usage example:
from wagtail.wagtailsnippets.models import register_snippet from wagtail.wagtailadmin.edit_handlers import StreamFieldPanel @register_snippet class Contact(models.Model): contact_info = StreamField([ ('email', MyBlocks.ContactEmail()), ('phone', MyBlocks.ContactPhone()), ('address', MyBlocks.ContactAddress()), ]) panels = [StreamFieldPanel('contact_info')]
Additional materials that you did not request: Streamfield is a field of the Django model, so it works the same on any model that you define. Actually Streamfield just saves a JSON string. The only thing that makes it different is blocks. The blocks defined in this first Streamfield parameter actually just define the available parameters that Streamfield can use to create the content. The blocks themselves are not related to SQL operations for CRUD, they are used only to manage the data stored for Streamfield.
Hope this helps.
source share