ArrayField in Django

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

Here is what the above code is Doing:
1. Creating a model named Book.
2. Creating a field named ratings.
3. The field ratings is an ArrayField.
4. The ArrayField contains FloatFields.

The ArrayField is a PostgreSQL-specific field type. It allows you to store an array of data in a single field.

The FloatField is a Django field type that allows you to store floating point numbers.

The ArrayField contains a list of FloatFields. Each FloatField represents a rating for the book.

The ratings field will store a list of ratings for the book. Each rating will be a floating point number between 1 and 5.

Now that you have a model with a ratings field, you can start storing ratings in the database.

To do this, you’ll need to create a view that accepts a POST request with a rating. The view will then create a Rating object and save it to the database.

Here’s what the view might look like: