Is it possible to store an array in Django model?

I’d have two advices for you:

1) Use ArrayField if you are using PostgreSQL as your database. You can read more about ArrayField here.

2) Encode your array as JSON and store it either as a plain string or using a JSONField as found here.

I’d personally prefer option number 1 since that is the cleaner and nicer way but depending on what you are actually using to store your data that might not be available to you.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)