如何在Django ORM中映射PostgreSQL数组字段 [英] How to map PostgreSQL array field in Django ORM
本文介绍了如何在Django ORM中映射PostgreSQL数组字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的PostrgreSQL数据库中有一个类型为文本的数组字段。有没有办法将其映射成Django模型?
I have an array field in my PostrgreSQL database of type text. Is there a way to map this into a Django model ?
推荐答案
您可能需要查看 django-dbarray 。它增加了对postgresql数组字段的支持。
You might want to look into django-dbarray on github. It adds support for postgresql array fields.
我以前没有使用过,但是您只需要做:
I haven't used it before, but it looks like you just need to do:
from django.db import model
import dbarray
class ProfilingTestRun(models.Model):
function = models.CharField(max_length=64)
runtimes = dbarray.FloatArrayField()
这篇关于如何在Django ORM中映射PostgreSQL数组字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文