0
看看我的模型的相關對象:訪問父類
class Gallery(models.Model):
HeadImage = models.ImageField(upload_to="gallery",editable=True,blank=True,null=True)
class Image(models.Model):
Image = models.ImageField(upload_to="gallery")
Gallery = models.ForeignKey(Gallery, related_name='images')
class Tour(Gallery):
Category=models.ForeignKey(TourCategory)
Name=models.CharField(max_length=100)
Count=models.SmallIntegerField()
現在,我有我想以旅遊對象的image_set訪問參觀的對象,有些事情是這樣的:
{% for i in tour.gallery_ptr.images.all %}
<img src="{{MEDIAL_URL}}{{i.Image.url}}" width="500px" height="400px"/>
{% endfor %}
但這不起作用,我該怎麼做?
我試了一下,但沒有錯誤!我可以訪問'tour.gallery_ptr.HeadImage'但'tour.gallery_ptr.images.all'沒有結果! – 2011-12-30 13:32:48