【发布时间】:2021-03-10 04:26:14
【问题描述】:
我目前在一家电子商店工作。所以我的想法是在 PgAdmin4 中存储带有 Django 模型的图像。正如我在较早的帖子中看到的那样,bytea('D:\image.jpg') 等方法只是将字符串常量转换为其二进制表示。
所以我的问题是是否有更新的方法来存储实际图像,或者是否可以通过路径抓取图像?
models.py
image = models.ImageField(null=True, blank=True)
PgAdmin4
INSERT INTO product_images(
id, image)
VALUES (SERIAL, ?);// how to insert image?
【问题讨论】:
-
您应该将其存储为 base64 字符串。有人在这里问stackoverflow.com/questions/36993615/…
标签: django postgresql image pgadmin-4