如何在Django模型中存储字符串数组? [英] How can I store an array of strings in a Django model?
本文介绍了如何在Django模型中存储字符串数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在构建Django数据模型,并且希望能够在其中一个变量中存储字符串数组;我该怎么办?
I am building a Django data model and I want to be able to store an array of strings in one of the variables; how can I do that?
例如
class myClass(models.Model):
title = models.CharField(max_length=50)
stringArr = models.???
感谢您的帮助。
推荐答案
制作另一个包含具有可选顺序的字符串的模型,为它提供一个 ForeignKey
回到 myClass
,然后将数组存储在其中。
Make another model that holds a string with an optional order, give it a ForeignKey
back to myClass
, and store your array in there.
这篇关于如何在Django模型中存储字符串数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文