How to map PostgreSQL array field in Django ORM

后端 未结 6 943
天命终不由人
天命终不由人 2020-12-10 12:33

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

6条回答
  •  我在风中等你
    2020-12-10 12:58

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

提交回复
热议问题