Django ImageField问题
我有一个类似的模型
Class Student(models.Model):
"""A simple class which holds the basic info
of a student."""
name = models.CharField(max_length=50)
age = models.PositiveIntegerField()
photo = models.ImageField(upload_to='foobar', blank=True, null=True)
从上面的代码可以看出,照片字段是可选的。我想要获取所有在学校数据库中有保存照片的学生。为此,我做了这个
>>> Student.objects.exclude(photo__name=None)
但是我遇到了这个错误:
FieldError: Join on field 'photo' not permitted.
那么,我该如何提取所有有照片的学生呢?
任何关于这个问题的帮助都非常感谢。提前谢谢大家。