Consider this model:
from django.contrib.postgres.fields import ArrayField
class Board(models.Model):
pieces = ArrayField(ArrayField(models.IntegerField()))
As a example, suppose that this is one of the values:
[[1,2], [3,4]]
I tried to access the values of this nd array, but I got list index out of range error.
Board= Board.objects.all()
final_list = [
{ "pieces_one": row.pieces[0][0],
"pieces_four": row.pieces[1][1]
} for row in Board
]
Any suggestion on accessing nd array filed's inner values? Of course, I am using Postgres as my database.
UPDATE: Actually the problem was another thing, and for accessing the inner values of a rectangular or any nd array, this method works fine with Django and Postgres.