我尝试从Digital Ocean空间中存储的图像制作图像。
当我做from django.core.exceptions import ValidationError
class PropertyImage(models.Model):
property = models.ForeignKey(Property, related_name='images')
image = models.ImageField()
is_front = models.BooleanField(default=False)
# Clean will only be called within the Admin.
# If you have other places this needs to be verified,
# you'll need to call it manually or move this logic into a ModelForm.
def clean(self):
images = self.property.images.all()
# If we're editing, we want to exclude ourselves from the check.
if self.id:
images = images.exclude(id=self.id)
if self.is_front and images.filter(is_front=True).exists():
raise ValidationError("Only one image can have is_front set.")
时说file_get_contents($urlToImage)
Image source not readable
有人知道是什么问题吗?