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 }}
精彩评论