How to map PostgreSQL array field in Django ORM

Nicu Surdu picture Nicu Surdu · Dec 9, 2010 · Viewed 7.7k times · Source

I have an array field in my PostrgreSQL database of type text. Is there a way to map this into a Django model ?

Answer

jcdyer picture jcdyer · Sep 19, 2011

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()