What is the difference in these two implementations of creating a carousel? They both seem to do the same thing, however one has Foreign Keys explicitly defined. The first implementation can easily be plugged in by calling it, meanwhile the second implementation has to be connected to a model via a ParentalKey. Essentially, which is the better option to to implement a carousel for display on a homepage?
class ImageCarouselBlock(blocks.StructBlock):
image = ImageChooserBlock()
caption = blocks.TextBlock(required=False)
page = PageChooserBlock()
class Meta:
icon = 'image'
class CarouselItem(LinkFields):
image = models.ForeignKey(
'wagtailimages.Image',
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name='+'
)
link_url = models.models.ForeignKey(
'wagtailcore.Page',
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name='+'
)
caption = models.CharField(max_length=255, blank=True)
panels = [
ImageChooserPanel('image'),
FieldPanel('link_url'),
FieldPanel('caption'),
MultiFieldPanel(LinkFields.panels, "Link"),
]
class Meta:
abstract = True