Django过滤器不使用查找对象

时间:2017-12-29 05:55:04

标签: python django django-rest-framework

我有下一个使用Django Rest Framework的代码

        images = ImageUploaded.objects.filter(offer__end_date > date.today())

但是,我收到了下一个错误:

  

全球名称' offer__end_date'未定义

ImageUploaded模型是下一个:

class ImageUploaded(models.Model):
    offer = models.ForeignKey(Offer, related_name='images', on_delete=models.DO_NOTHING)
    image = models.ImageField("Uploaded image")

优惠模式是:

class Offer(models.Model):
ARGENTINA = 'ARG'
URUGUAY = 'URG'
COUNTRIES = (
    (ARGENTINA, 'Argentina'),
    (URUGUAY, 'Uruguay')
)

name = models.CharField(max_length=200)
description = models.TextField()
created = models.DateField(auto_now_add=True)
end_date = models.DateField()
available = models.IntegerField()
current = models.IntegerField(default=0)

我感谢任何帮助!

0 个答案:

没有答案