Last active
August 29, 2015 13:59
-
-
Save kaedroho/10968400 to your computer and use it in GitHub Desktop.
This file contains 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 django.db import models | |
from modelcluster.fields import ParentalKey | |
from wagtail.wagtailcore.models import Page, Orderable | |
from wagtail.wagtailadmin.edit_handlers import FieldPanel, InlinePanel | |
class Thing(models.Model): | |
... | |
class PageThings(models.Model): # Inherit from Orderable if you would like reorder | |
page = ParentalKey('myapp.MyPage', related_name='things') | |
thing = models.ForeignKey(Thing, related_name='pages') | |
panels = [ | |
FieldPanel('thing') | |
] | |
class MyPage(Page): | |
... | |
def get_things(self): | |
return Thing.objects.filter(pages__page=self) | |
MyPage.content_panels = [ | |
InlinePanel(MyPage, 'things', label="Things"), | |
... | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment