0
我想驗證幾個圖像字段,我不知道是否可以使用表示字段名稱的變量和for循環來遍歷模型的屬性?自己可以用來訪問對象屬性嗎?
class Guitar(models.Model):
images0 = models.ImageField(upload_to='images', blank=True)
def clean(self):
images = ['images0', ...]
for idx, val in enumerate(images):
if self[val].size > 2000000:
所以有可能使用這樣的self
?
self[val].size == self.images0.size