:だからimagekitDjangoのimagekitとに設けたダイナミックなパス
、私が定義した2つのクラスモデル:
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
問題は、各写真は、「静的に作成されていることです/写真 "パス。 国名に基づいて画像とサムネイルを動的パスで保存することです。
たとえば、国「Argentina」の場合、動的パスは「static/photos/Argentina /」になります
どうすれば実現できますか?