在详图页上显示同一型号的相关项目

2024-05-18 08:20:08 发布

您现在位置:Python中文网/ 问答频道 /正文

我在做新闻模型。我有一个列表页和一个详细页。 我需要在详细信息页面与选择其他相关的新闻在管理面板,并保存在网站上的选项

我的型号:

class News(models.Model):
    title = models.CharField(max_length=500)
    subtitle = models.CharField(max_length=1000, blank=True)
    text = models.TextField()
    link = models.ForeignKey('.'.join(LINK_MODEL), null=True, blank=True)
    link_title = models.CharField(max_length=500)
    date = models.DateField(null=True)
    image = FilerImageField()

    class Meta:
        verbose_name_plural = 'news'
        ordering = ['-date']

我应该用外键吗


Tags: 模型true列表datetitlemodelslink详细信息