嗨,我必须遵循模型 class Match(models.Model):
Team_one = models.ForeignKey('Team', related_name='Team_one')
Team_two = models.ForeignKey('Team', related_name='Team_two')
Stadium = models.CharField(max_length=255, blank=True)
Start_time = models.DateTimeField(auto_now_add=False, auto_now=False, blank=True, null=True)
Rafree = models.CharField(max_length=255, blank=True)
Judge = models.CharField(max_length=255, blank=True)
Winner = models.ForeignKey('Team', related_name='winner', blank=True)
updated = models.DateTimeField('update date', auto_now=True )
created = models.DateTimeField('creation date', auto_now_add=True )
def save(self, force_insert=False, force_update=False):
pass
@models.permalink
def get_absolute_url(self):
return ('view_or_url_name')
class MatchAdmin(admin.ModelAdmin):
list_display = ('Team_one','Team_two', 'Winner')
search_fields = ['Team_one','Team_tow']
admin.site.register(Match, MatchAdmin)
我想知道,一旦在管理网站中选择了第一队和第二队,他们就可以填充获胜者组合框吗?
答案 0 :(得分:1)
使用django管理员并没有真正简单的方法。这是可能的,但它需要您替换管理表单,并使用一些将团队复制到框中的JavaScript来子集窗口小部件。比它的价值更多的努力。
如果我是你,我只会有winner_team和loser_team字段
答案 1 :(得分:0)