class StandardPageRelatedSnippet(Orderable, Snippet): page = ParentalKey('cms.StandardPage', related_name='snippets')
snippet = models.ForeignKey('cms.Snippet', related_name='+')
panels = [ SnippetChooserPanel('snippet', Snippet), ]
...
StandardPage.content_panels = [ #...
InlinePanel('snippets', label="Related snippets"),
]class GalleryItem(models.Model):
image = models.ForeignKey(
'wagtailimages.Image', null=True, blank=True,
on_delete=models.SET_NULL, related_name='+')
source = models.CharField(
max_length=255, verbose_name=_('Source'),
help_text=_('Author/Origin of an image.'))
alt_text = models.CharField(
max_length=255, blank=True, default='',
help_text=_('Text displayed in image alt tag.'))
description = models.CharField(
max_length=255, blank=True, default='',
help_text=_('Short description of an image'))
panels = [
ImageChooserPanel('image'),
FieldPanel('source'),
FieldPanel('alt_text'),
FieldPanel('description')
]
class Meta:
abstract = True
class GallerySnippetGalleryItems(Orderable, GalleryItem):
item = ParentalKey(
'core.GallerySnippet', related_name='related_gallery_items')
@python_2_unicode_compatible
@register_snippet
class GallerySnippet(ClusterableModel):
title = models.CharField(max_length=80, verbose_name=_('Gallery title'))
created_at = models.DateField(verbose_name=_('Date created'))
panels = [
FieldPanel('title', classname='col8'),
FieldPanel('created_at', classname='col4'),
InlinePanel('related_gallery_item', label='Item')
]
def __str__(self):
return self.title
class GallerySnippetGalleryItems(Orderable, GalleryItem):
item = ParentalKey(
'galleries.GallerySnippet', related_name='related_gallery_items')
class Meta:
verbose_name = _('Gallery item')
verbose_name_plural = _('Gallery items')
Hey Scott, I'm reviving this thread as I'm running into exactly the problem you had, I'm on Wagtail 1.8 and have followed the example from the documentation here.Did you ever find out what was causing your issue?
This way "ordering" defined in Orderable class was not applied. To fix it, either don't define class Meta or put "ordering = ['sort_order']" in newly defined class Meta.