Use array in postgresql with django
Posted 27.01.2013 · 1 min readI wanted to use arrays in postgresql for tags on this blog. I installed the packages
djorm-ext-pgarray
and djorm-ext-expressions
. The model for the blogposts is displayed below.
from django.db import modelsfrom djorm_expressions.models import ExpressionManagerfrom djorm_pgarray.fields import ArrayField
class Post (models.Model): title = models.CharField(max_length=80) slug = models.SlugField() pub_date = models.DateField() content = models.TextField() tags = ArrayField(dbtype="varchar(60)") objects = ExpressionManager()
The tags field is using djorm_pgarray.fields.ArrayField
and the ExpressionManagaer is
needed if one would need to make a query using the ArrayField.
#tags, #postgres, #array, #pgarray, #django