Django装置中的图像? [英] Images in Django fixtures?

查看:161
本文介绍了Django装置中的图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在文档中查看Django灯具,没有提到将图像预加载到数据库中。我不能成为唯一需要这样做的人。这可能吗?如果是这样的话如果没有,是否有任何解决方法可用?

I was looking at Django fixtures in the docs, there was no mention of preloading images into the database. I can't be the only who needed to do this. Is this possible? If so how? If not, are there any workarounds available?

请谢谢。

推荐答案

是的,这是可能的。
您必须将您的图像放在项目MEDIA_ROOT中。
在装置中,它将看起来像

Yes, it's possible. You have to put your image in your project MEDIA_ROOT. In fixtures it will look like

[{
    "pk": 1,
    "model": "pictures.picture",
    "fields": {
        "image": "/media/gebakken_kip_met_korianderrijst_1152_x_1728.png"

    }
}]

这篇关于Django装置中的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆