I have a model that is backed by a database table that contains a read-only column that is maintained by the database using Postgresql's Generated Columns (i.e. using GENERATED ALWAYS AS) - see
https://www.postgresql.org/docs/current/ddl-generated-columns.html.
When Django saves the model, it tries to set the field, which throws `django.db.utils.ProgrammingError: cannot insert into column "_search". DETAIL: Column "_search" is a generated column.
Is there any way to tell Django not to attempt to insert that field?
From what I can tell `editable=False` doesn't prevent Django from trying to save it - which makes sense for fields that aren't editable by users but are calculated by the model class, e.g. in `save()`.
I know I could set `something like `instance.save(update_fields=[field for field in instance._meta.fields if
field.name != "_search")` but it would need to be set on every save for that model throughout the application, which seems like a lot of technical debt and likely to trip up other developers as they maintain the application.
Is there anything that I can set on the field instance in the model to tell Django that it is maintained by the database?
If not, please can anyone suggest a way to add code to the model to make it ignore the field when saving?
Thanks
Roger