Our great sponsors
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
# guide/models.py from django.db import models from modelcluster.fields import ParentalKey from modelcluster.models import ClusterableModel from wagtail.admin.edit_handlers import ( FieldPanel, InlinePanel, ObjectList, TabbedInterface, ) from wagtail.core.models import Orderable class GuideStep(models.Model): """ Each step is a model to represent the step used by https://shepherdjs.dev/docs/Step.html This is an abstract model as `GuideRelatedStep` will be used for the actual model with a relation """ title = models.CharField(max_length=255) text = models.CharField(max_length=255) element = models.CharField(max_length=255, blank=True) panels = [ FieldPanel("title"), FieldPanel("text"), FieldPanel("element"), ] class Meta: abstract = True class GuideRelatedStep(Orderable, GuideStep): """ Creates an orderable (user can re-order in the admin) and related 'step' Will be a many to one relation against `Guide` """ guide = ParentalKey("guide.Guide", on_delete=models.CASCADE, related_name="steps") class Guide(ClusterableModel): """ `ClusterableModel` used to ensure that this model can have orderable relations using the modelcluster library (similar to ForeignKey). edit_handler """ title = models.CharField(max_length=255) # steps - see GuideRelatedStep url_path = models.CharField(max_length=255, blank=True) content_panels = [ FieldPanel("title"), InlinePanel("steps", label="Steps", min_num=1), ] settings_panels = [ FieldPanel("url_path"), ] edit_handler = TabbedInterface( [ ObjectList(content_panels, heading="Content"), ObjectList(settings_panels, heading="Settings"), ] )
It is assumed that you will have a Wagtail application running, if not you can use the Wagtail Bakery Demo as your starting point.
Each MenuItem has a method get_context which provides the template context to the menu_item.html template.
You can see all the final code on github https://github.com/lb-/bakerydemo/tree/tutorial/guide-app/guide