我创建了Relationshim模型以在InlinePanel
内使用,所以如果我点击选择一个页面我什么都没得到
这是我的models.py:
class GroupstageTournamentModel(ClusterableModel):
number = models.PositiveSmallIntegerField(
default="", verbose_name="Match №:")
starts_at = models.DateTimeField(default="",)
# Team 1
team_1 = models.ForeignKey(
TeamRooster,
null=True, default="", verbose_name='Erste Team',
on_delete=models.SET_NULL,
related_name="+",
)
team_1_dress = ColorField(default='#ff0000', blank=True, verbose_name='Dress')
team_1_first_halftime_score = models.PositiveSmallIntegerField(blank=True, default="0", verbose_name='Resultat 1. HZ')
team_1_first_halftime_point = models.PositiveSmallIntegerField(blank=True, default="0", verbose_name='Punkte 1. HZ')
team_1_second_halftime_score = models.PositiveSmallIntegerField(blank=True, default="0", verbose_name='Resultat 2. HZ')
team_1_second_halftime_point = models.PositiveSmallIntegerField(blank=True, default="0", verbose_name='Punkte 2. HZ')
team_1_shootout_score = models.PositiveSmallIntegerField(blank=True, default="0", verbose_name='Resultat Shootout')
team_1_shootout_point = models.PositiveSmallIntegerField(blank=True, default="0", verbose_name='Schootout Punkte')
team_1_total_score = models.PositiveSmallIntegerField(blank=True, default="0", verbose_name='Resultat Total')
team_1_total_points = models.PositiveSmallIntegerField(blank=True, default="0", verbose_name='Punkte Total')
# Team 2
team_2 = models.ForeignKey(
TeamRooster,
null=True, default="", verbose_name='Zweite Team',
on_delete=models.SET_NULL,
related_name="+",
)
team_2_dress = ColorField(default='#ff0000', blank=True, verbose_name='Dress')
team_2_first_halftime_score = models.PositiveSmallIntegerField(blank=True, default="0", verbose_name='Resultat 1. HZ')
team_2_first_halftime_point = models.PositiveSmallIntegerField(blank=True, default="0", verbose_name='Punkte 1. HZ')
team_2_second_halftime_score = models.PositiveSmallIntegerField(blank=True, default="0", verbose_name='Resultat 2. HZ')
team_2_second_halftime_point = models.PositiveSmallIntegerField(blank=True, default="0", verbose_name='Punkte 2. HZ')
team_2_shootout_score = models.PositiveSmallIntegerField(blank=True, default="0", verbose_name='Resultat Shootout')
team_2_shootout_point = models.PositiveSmallIntegerField(blank=True, default="0", verbose_name='Schootout Punkte')
team_2_total_score = models.PositiveSmallIntegerField(blank=True, default="0", verbose_name='Resultat Total')
team_2_total_points = models.PositiveSmallIntegerField(blank=True, default="0", verbose_name='Punkte Total')
panels = [
FieldPanel('number', classname="col6"),
FieldPanel('starts_at', classname="col6"),
# Team 1
FieldPanel('team_1', classname="col9"),
FieldPanel('team_1_dress', classname="col3"),
FieldPanel('team_1_first_halftime_score', classname="col3"),
FieldPanel('team_1_second_halftime_score', classname="col3"),
FieldPanel('team_1_shootout_score', classname="col3"),
FieldPanel('team_1_total_score', classname="col3"),
FieldPanel('team_1_first_halftime_point', classname="col3"),
FieldPanel('team_1_second_halftime_point', classname="col3"),
FieldPanel('team_1_shootout_point', classname="col3"),
FieldPanel('team_1_total_points', classname="col3"),
# Team 2
FieldPanel('team_2', classname="col9"),
FieldPanel('team_2_dress', classname="col3"),
FieldPanel('team_2_first_halftime_score', classname="col3"),
FieldPanel('team_2_second_halftime_score', classname="col3"),
FieldPanel('team_2_shootout_score', classname="col3"),
FieldPanel('team_2_total_score', classname="col3"),
FieldPanel('team_2_first_halftime_point', classname="col3"),
FieldPanel('team_2_second_halftime_point', classname="col3"),
FieldPanel('team_2_shootout_point', classname="col3"),
FieldPanel('team_2_total_points', classname="col3"),
]
def __str__(self):
return '{} vs {} {} - {}'.format(self.team_1, self.team_2, self.starts_at, self.number)
class Meta:
verbose_name = 'Gruppenphase Spiel'
verbose_name_plural = 'Gruppenphase'
class GroupstageScreencastRelationship(Orderable, models.Model):
page = ParentalKey('ScreencastPage',
related_name='groupstage_screencast_relationship')
match = models.ForeignKey('GroupstageTournamentModel',
related_name='match_screen_relationship')
panels = [
PageChooserPanel('match')
]
class ScreencastPage(Page):
content_panels = Page.content_panels + [
InlinePanel(
'groupstage_screencast_relationship', label="Playing First",
panels=None, max_num=1),
]
parent_page_types = ['home.HomePage']
如果我点击选择控制台追溯中的页面,我会看到以下内容:
Not Found: /admin/choose-page/
[12/Feb/2018 15:09:03] "GET /admin/choose-page/?page_type=tournament.groupstagetournamentmodel HTTP/1.1" 404 4621
Not Found: /admin/choose-page/
[12/Feb/2018 15:09:04] "GET /admin/choose-page/?page_type=tournament.groupstagetournamentmodel HTTP/1.1" 404 4621
Not Found: /admin/choose-page/
[12/Feb/2018 15:09:05] "GET /admin/choose-page/?page_type=tournament.groupstagetournamentmodel HTTP/1.1" 404 4621
Not Found: /admin/choose-page/
[12/Feb/2018 15:09:05] "GET /admin/choose-page/?page_type=tournament.groupstagetournamentmodel HTTP/1.1" 404 4621
我还首先创建了GroupstageTournamentModel(ClusterableModel)
个模型。
答案 0 :(得分:1)
这是失败的,因为GroupstageTournamentModel
不会从Page继承 -
PageChooserPanel
不适用于非页面模型。您可以将GroupstageTournamentModel
注册为片段(http://docs.wagtail.io/en/v1.13.1/topics/snippets.html)并使用SnippetChooserPanel
,也可以使用普通的FieldPanel(这将为您提供简单的下拉列表)。