Skip to content
Advertisement

How can I store an array of strings in a Django model?

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?

e.g.

class myClass(models.Model):
    title = models.CharField(max_length=50)
    stringArr = models.???

Thanks for the help.

Advertisement

Answer

Make another model that holds a string with an optional order, give it a ForeignKey back to myClass, and store your array in there.

Advertisement