Django and the curious case of the disappearing materialized view https://craiga.id.au/2026/05/14/disappearing-materialized-view
Django and the curious case of the disappearing materialized view

A project I’ve been working on depends on a number of materialized views, a nifty feature of Postgres which is somewhere between a traditional view and a table.

Craig Anderson
@craiga have you looked at any of the Django views libraries to see if they handle this?
@CodenameTim No, all of the views we work with are created by Postgres consultants in SQL. There's some pretty wild stuff going on which didn't fit into what those Django view libraries were able to provide the last time I looked.
@craiga @CodenameTim mark the model as unmanaged and Django won't create migrations for it
@markush @CodenameTim The column is being removed from a managed model. It's a view which uses that column that disappears without warning. I really should log an issue in Django about this…
@markush @CodenameTim Turns out this was fixed in Django 6: "BaseDatabaseSchemaEditor and PostgreSQL backends no longer use CASCADE when dropping a column" (https://docs.djangoproject.com/en/6.0/releases/6.0/#database-backend-api)
Django 6.0 release notes | Django documentation

The web framework for perfectionists with deadlines.

Django Project