3👍
Problem
The field merchants
is a list but by default it is null.
Solution
So the best things to do is set a default=list
.
Error Explanation
Array value must start with "{" or dimension information.
This occurs because you are puttting a variable inside a list, instead do this self.merchants = [merchant_id, ]
‘NoneType’ object has no attribute ‘append’
This occurs because you have a None, not a list. Make an empty list the default value or set it by code: self.merchants = list()
0👍
Further to this, my context was adding an ArrayField to a Django model, and on initial migration failing because I was passing it a string as a default, which the migration file referenced and failed out on when it interfaced with PSQL.
Solved this by hand-editing the migration file, finding the initial migration default string and putting brackets around the string.
Doesn’t happen on future instances as I think the ArrayField implementation explicitly casts a comma separated list with brackets as part of the save operation, just not on the initial migration if it’s expecting a default.
- [Django]-How can I omit time at HTML {{ post.published_date }} tag?
- [Django]-How would I write a CSV file populated with my sqlite3 db?
- [Django]-Show user posts in post list