Reputation: 42
I used Django ArrayField with Postgres Database, I read the documentation however I cannot find a method to retreive all values saved inside the array field.
After retrieved the record from database, I want to convert ArrayField type into python list type.
Upvotes: 2
Views: 2160
Reputation: 612
Simply instanciate the target object and retrieve the information from the attribute name
My model: I think you want something this:
from django.contrib.postgres.fields import ArrayField
class ModelTest(models.Model):
board = ArrayField(
ArrayField(
models.IntegerField(),
size=2,
),
size=2,
)
My test is, first create one object and get the object, next i retrieve board attribute:
The return is a list of list in python
Upvotes: 2