from model_utils.managers import InheritanceManager
class Property(models.Model):
title = models.CharField(max_length=255)
slug = models.SlugField()
desc = models.TextField()
objects = InheritanceManager()
class Apartament(Property):
bedrooms = models.IntegerField()
levels = models.IntegerField()
something = models.CharField(max_length=255)
意见:
p = Property.objects.get(slug=slug)
return render_to_response(...{'p':p} ...)
模板:
{{ p.title }}
我可以从 访问这些字段Apartament
吗?例如:
{{ p.bedrooms }}
如何在我的模板中获得卧室?