Created
October 9, 2016 21:08
-
-
Save pjho/f0bbcfc745989191cf305a34233388e0 to your computer and use it in GitHub Desktop.
Wagtail Related Inline Model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from modelcluster.fields import ParentalKey | |
from wagtail.wagtailcore.models import Page, Orderable | |
# The Parent/Consuming page | |
class ExamplePage(Page): | |
content_panels = Page.content_panels + [ | |
InlinePanel('related_sub_model_label', label="Ui Heading for inline model"), | |
] | |
# The abstract class defining the fields. Can be named whatever. | |
class RelatedSubFieldsClass(models.Model): | |
heading = models.TextField() | |
panels = [ | |
FieldPanel('heading'), | |
] | |
class Meta: | |
abstract = True | |
# The class that creates the relationship | |
class RelatesSubFieldToPage(Orderable, RelatedSubFieldsClass): | |
page = ParentalKey('ExamplePage', related_name='related_sub_model_label') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment