class BreadsIndexPage(Page): """ Index page for breads. This is more complex than other index pages on the bakery demo site as we've included pagination. We've separated the different aspects of the index page to be discrete functions to make it easier to follow """ introduction = models.TextField(help_text="Text to describe the page", blank=True) image = models.ForeignKey( "wagtailimages.Image", null=True, blank=True, on_delete=models.SET_NULL, related_name="+", help_text="Landscape mode only; horizontal width between 1000px and 3000px.", )
class Country(models.Model): """ A Django model to store set of countries of origin. It is made accessible in the Wagtail admin interface through the CountrySnippetViewSet class in wagtail_hooks.py. """ title = models.CharField(max_length=100) sort_order = models.IntegerField(null=True, blank=True, db_index=True) class Meta: verbose_name = "country of origin" verbose_name_plural = "countries of origin"
Country uses a simple model (not ClusterableModel) and is registered as a snippet through CountrySnippetViewSet in wagtail_hooks.py.
class BreadIngredient(Orderable, DraftStateMixin, RevisionMixin, models.Model): """ A Django model to store a single ingredient. It uses DraftStateMixin and RevisionMixin to support drafts and revisions. """ name = models.CharField(max_length=255) revisions = GenericRelation( "wagtailcore.Revision", content_type_field="base_content_type", object_id_field="object_id", related_query_name="bread_ingredient", for_concrete_model=False, ) panels = [ FieldPanel("name"), ] class Meta: verbose_name = "bread ingredient" verbose_name_plural = "bread ingredients" ordering = ["sort_order", "name"]
class BreadType(RevisionMixin, models.Model): """ A Django model to define the bread type It is made accessible in the Wagtail admin interface through the BreadTypeSnippetViewSet class in wagtail_hooks.py. """ title = models.CharField(max_length=255) revisions = GenericRelation( "wagtailcore.Revision", content_type_field="base_content_type", object_id_field="object_id", related_query_name="bread_type", for_concrete_model=False, ) panels = [ FieldPanel("title"), ] class Meta: verbose_name = "bread type" verbose_name_plural = "bread types"
BreadType includes RevisionMixin for tracking changes but does not have draft/live states.