'django create a field that hold array of tupels or array of array
I want to add a field in my models that hold value like this
field = [(1,2,3),(6,5,4),(5,6,7)]
or
field = [[1,2,3],[6,5,4],[5,6,7]]
I am using postgresql db. how to achieve this.
Solution 1:[1]
In django docs
, its stated as:
from django.contrib.postgres.fields import ArrayField
from django.db import models
class Board(models.Model):
pieces = ArrayField(ArrayField(models.IntegerField()))
# Valid
Board(pieces=[
[2, 3],
[2, 1],
])
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Sunderam Dubey |