: 그래서 imagekit장고 imagekit 및 제공 동적 경로
, 내가 정의한 두 개의 클래스 모델 :
class Photo(models.Model):
#photo_wrapper = models.ForeignKey(PhotoWrapper, blank=True, null=True)
original_image = models.ImageField(upload_to='static/photos')
thumbnail = ImageSpec([Adjust(contrast=1.2, sharpness=1.1),
resize.Crop(50, 50)], image_field='original_image',
format='JPEG', quality=90)
num_views = models.PositiveIntegerField(editable=False, default=0)
class IKOptions:
# This inner class is where we define the ImageKit options for the model
spec_module = 'myspecs.specs'
cache_dir = 'static/photos'
image_field = 'original_image'
save_count_as = 'num_views'
class Country(models.Model):
country_name = models.CharField(max_length=250)
country_photo = models.ForeignKey(Photo, blank=True, null=True)
def __unicode__(self):
return '%s' % self.country_name
문제는 각 사진은 "정적에서 생성된다는 것이다/사진 "경로. 내 의도는 "정적/사진/아르헨티나 /"국가 "아르헨티나"에 대한 동적 경로가 될 것, 예를 들어
.. 이미지와 국가 이름을 기반으로 동적 경로 썸네일을 저장하는 것입니다
어떻게하면됩니까?