django-photologue upload_to
我已经使用 django-photologue 一段时间了,发现它是所有其他图像处理应用程序的绝佳替代品。
但有一件事是,我还使用 django-cumulus 来将上传内容推送到 CDN,而不是在本地计算机/服务器上运行。
当我使用 imagekit 时,我总是可以传递 upload_to='whatever'
但我似乎无法使用 photologue 执行此操作,因为它会自动插入图像字段。我将如何实现某种覆盖?
问候
I have been playing around with django-photologue
for a while, and find this a great alternative to all other image handlings apps out there.
One thing though, I also use django-cumulus
to push my uploads to my CDN instead of running it on my local machine / server.
When I used imagekit, I could always pass a upload_to='whatever'
but I cannot seem to do this with photologue as it automatically inserts the imagefield. How would I go about achieving some sort of an overwrite?
Regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为您可以在将实例保存到数据库之前连接到照片模型的 pre_save 信号,并更改 upload_to 字段。
看看这个:
http://docs.djangoproject.com/en/dev/topics/signals/< /a>
I think you can hook into the pre_save signal of the Photo model, and change the upload_to field, just before the instance is saved to the database.
Take a look at this:
http://docs.djangoproject.com/en/dev/topics/signals/
设法找到解决方法,但这需要您在 photologue/models.py 中进行更改
,然后在您的应用程序模型中执行以下操作:
Managed to find a workaround for it, however this requires you to make the changes in photologue/models.py
And then in your apps models do the following:
您可以使用设置 PHOTOLOGUE_PATH 来提供您自己的可调用项。定义一个以实例和文件名作为参数的方法,然后返回您想要的任何内容。例如,在您的settings.py中:
大概(虽然我没有测试过这一点)您可以找到有关 Photo 实例的更多信息(例如它涉及的其他实例)并相应地选择文件夹。
You can use the setting PHOTOLOGUE_PATH to provide your own callable. Define a method which takes instance and filename as parameters then return whatever you want. For example in your settings.py:
Presumably (although I've not tested this) you could find out more about the Photo instance (e.g. what other instances it relates to) and choose the folder accordingly.