2

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.

This is their documentation

1 Answer 1

2

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:

enter image description here

The return is a list of list in python

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.