我有两个模型,如下所述,它们彼此相关,我想在另一个模型的表中显示一个模型的不同出现。
这是针对带有djanto-tables2插件的Django#2.2。
# models.py
class Example1(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
title = models.CharField(max_length=250, blank=False)
class Example2(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
title = models.CharField(max_length=250, blank=False)
example1 = models.ForeignKey(Example1, on_delete=models.CASCADE)
#tables.py
class Example1Table(tables.Table):
title = tables.Column(verbose_name=_('Título'))
# I want here a column to show all Example2 related with this Example1 object
class Meta:
model = Example1
exclude = []