我将 Django ArrayField 与 Postgres 数据库一起使用,我阅读了文档,但是我找不到一种方法来检索保存在数组字段中的所有值。从数据库中检索记录后,我想将 ArrayField 类型转换为 python 列表类型。
1 回答

qq_遁去的一_1
TA贡献1725条经验 获得超7个赞
简单地实例化目标对象并从属性名称中检索信息
我的模型:我想你想要这样的东西:
from django.contrib.postgres.fields import ArrayField
class ModelTest(models.Model):
board = ArrayField(
ArrayField(
models.IntegerField(),
size=2,
),
size=2,
)
我的测试是,首先创建一个对象并获取该对象,然后我检索板属性:
返回是python中的列表列表
添加回答
举报
0/150
提交
取消