Django ArrayField - a PostgreSQL-specific field A basic ArrayField


Example

To create a PostgreSQL ArrayField, we should give ArrayField the type of data we want it to store as a field as its first argument. Since we'll be storing book ratings, we will use FloatField.

 from django.db import models, FloatField
 from django.contrib.postgres.fields import ArrayField
 
 class Book(models.Model):
     ratings = ArrayField(FloatField())