Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果数据类型(文本/图像/html)未知,应该使用 django 模型类中的哪个字段?我正在寻找一个可以处理复制和粘贴的 html 代码、图像、文本等的字段。
任何文本信息:TextField
任何二进制信息(除了 jpg、gif、png):FileField
任何图像:ImageField
FileField 和 ImageField 的数据作为文件存储在硬盘上,只留下文件的路径,包括数据库字段中的文件名。(这是一个性能特征!)
我不会将表中的一个字段用于所有三种类型的数据,但让 a) 用户指定这是图像还是某些文本,或者 b) 通过使用诸如 unixfile命令之类的工具检查文件来决定自己。
file