Q:

Django tries to write to a generated column

I've added GIN index to my db
ALTER TABLE mtn_order
ADD COLUMN textsearchable_index_col tsvector
GENERATED ALWAYS AS (to_tsvector('english', coalesce(descr, '') || ' ' || coalesce(descrrep, ''))) STORED;
CREATE INDEX textsearch_idx ON mtn_order USING GIN (textsearchable_index_col);

and textsearchable_index_col = SearchVectorField(null=True) to my model and now when i'm trying to save new instance i get:
ProgrammingError at /order/create/
cannot insert into column "textsearchable_index_col"
DETAIL:  Column "textsearchable_index_col" is a generated column.

How to stop Django trying to write None to that field

A:

You won't be able to add it as a field to your model, because Django will try to write values back to it.
You could annotate it on when you need to:
MyModel.objects.annotate(
    index_col=RawSQL('textsearchable_index_col', 
                     [], 
                     output_field=SearchVectorField()
)

