4

so lets say I have the following models set up for Wagtail:

@register_snippet
class MySnippet(models.Model):
    name = models.CharField(max_length=200, null=True)
    panels = [FieldPanel('name'),]
    def __str__(self):
        return self.name
    class Meta:
        ordering = ['name',]

class MyPage(Page):
    body = StreamField([
        ('mysnippet', SnippetChooserBlock(required=False, label='MySnippet', target_model='MySnippet')),
    ], blank=True, help_text='')

    content_panels = Page.content_panels + [
        StreamFieldPanel('body', heading='Stuff to add'),
    ]

My client will be creating a lot of MySnippet items as they go. It's going to be super awkward for them to move to another view in their CMS, create a MySnippet, then come back to their main MyPage editor to choose it.

Q1 Is there a simple way to add a SnippetChooseOrInlineCreate() block so clients can add new MySnippets as they create MyPages?

Q2 If there's no existing simple way, how would you recommend approaching this?

thclark
  • 4,784
  • 3
  • 39
  • 65

0 Answers0