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.
You can use some serialization mechanism like JSON. There's a snippet with field definition that could be of some use to you:
http://djangosnippets.org/snippets/1478/ (take a look at the code in the last comment)
With such field you can seamlessly put strings into a list and assign them to such field. The field abstraction will do the rest. The same with reading.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With