How to map PostgreSQL array field in Django ORM

后端 未结 6 920
天命终不由人
天命终不由人 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 13:15

    Since Django 1.8 there is a django.contrib.postgress module that adds support to array fields among other PostgreSQL data types.

    For example you can do something like this:

    from django.contrib.postgres.fields import ArrayField
    from django.db import models
    
    class GoGame(models.Model):
        board = ArrayField(ArrayField(models.IntegerField(),size=19),size=19)
    

提交回复
热议问题