简体   繁体   English

Django:如何将图像存储在数据库中而不是媒体文件中?

[英]Django:How to store images in database instead of media file?

I want to store images in database for various users.Its just like famous blog app but instead of blogs i want to store images in database.How can i implement my idea?我想将图像存储在数据库中以供各种用户使用。它就像著名的博客应用程序,但我想将图像存储在数据库中而不是博客。我该如何实现我的想法?

You can do one thing -> change the image into base64 string and save it to database than when you want that image convert it from base64 to normal format.您可以做一件事-> 将图像更改为 base64 字符串并将其保存到数据库,而不是将其从 base64 转换为正常格式。 and you can find multiple tutorial on internet how to change image to base64 in python.您可以在互联网上找到多个教程如何在 python 中将图像更改为 base64。 why i am suggesting this because i used it in an android app.为什么我建议这样做,因为我在 android 应用程序中使用了它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Django 显示来自媒体文件而不是数据库的图像 - Django displaying images from media file instead of database 如何将csv文件存储到Django中的数据库中? - How to store csv file to database in django? 如何在Django中处理上传的文件以将其存储在数据库中 - How to handle an uploaded file in Django to store it in the database 如何停止Django将图像路径存储在sqlite3数据库中 - How to stop django to store images path in sqlite3 database 如何将存储在媒体文件夹中数据库中的 pdf 文件邮寄给用户-Django - How to mail a pdf file stored in the database in the media folder to a user -Django 如何使用 django 在 Mysql 数据库中存储文件路径? - How can I store a file path in Mysql database using django? sqlalchemy在数据库中存储媒体 - sqlalchemy store media in the database 如何使用models.FileField将文件保存在数据库中而不是上传到服务器媒体文件夹中? - How to Save file in database instead of upload in server media folder ,using models.FileField? 如何在 django 中存储基于特定用户的图像? - How to store images based on a particular user in django? Django:将gmt时间存储在数据库表中,而不是本地时间 - Django: Store gmt time in database table instead of local time
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM