开发者

Accessing Django OneToOneField in templates?

I have the following scenario.

class A(models.Model):
    a = models.IntegerField()

class B(models.Model):
    c = models.OneToOneField(A)
    d = models.DecimalField()

In my templates, I have a list of objects A. In my template how do I access the attribute "d" from my template?

Than开发者_如何学JAVAks.


class B(models.Model):
    c = models.OneToOneField(A, related_name='b')
    d = models.DecimalField()

{{ a.b.d }}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜