我有两种模式:
(x,y,z)
我的验证器获取Photo.id ForeignKey,获取Photo对象:
class Photo(models.Model):
# photo attributes and methods
class Category(models.Model):
banner = models.ForeignKey(Photo, validators=[validate_image_size])
有没有办法将Photo对象传递给验证器?而不是def validate_image_size(photo_id):
photo = Photo.objects.get(id=photo_id)
# open the image using urllib
# if image size too large, raise ValidationError()
。