我正在 Django 应用程序中实现 ImageKit,据我所知,我已经正确设置了所有内容。当我运行命令时
$python manage.py ikflush main
该命令似乎运行良好,但似乎没有发生任何事情。没有图像被调整大小或存储并且无法访问。
主模型.py:
class ProductImage(models.Model):
product = models.ForeignKey(Product)
image = models.CharField(max_length=255, null=True, blank=True)
original = models.ImageField(upload_to='uploads/product-images/zoom/')
class IKOptions:
spec_module = 'main.specs'
cache_dir = 'uploads/cache'
image_field = 'original'
main.specs.py:
from imagekit.specs import ImageSpec
from imagekit import processors
class ResizeSmall(processors.Resize):
width = 230
height = 289
crop = False
class SmallImage(ImageSpec):
access_as = 'small_image'
pre_cache = True
processors = [ResizeSmall]
在模板中:(不打印)
{% for image in images %}
{{ image.small_image }}<br />
{% endfor %}
有人对如何调试有任何想法吗?我真的很想为此使用 ImageKit,但我以前从未实现过它。提前致谢!