django.db.utils.NotSupportedError when attempting to change max_length on CharField

I have the following field:

    name_combined = models.CharField(
        max_length=600,
        editable=False,
    )

which is a field that combines two Charfields on save. I have found that 600 is too small. As I have taken over the project it is in production - so cannot simply rollback migrations to zero and start again.

Changing the max_length or the field to a text field results in the following error:

django.db.utils.NotSupportedError: cannot alter type of a column used by a view or rule
DETAIL:  rule _RETURN on view v_viewing_report depends on column "name_combined"

it is a Postgres database. What do rules and views mean in this context and how do you go about changing the max_length or field type to allow for the change?

Still interested by the meaning of “view” or “rules” in the Postgres context, but have decided to truncate the characters to 600 when creating ‘name_combined’.

It is a niche case which was only found with the use of model bakery, and will rarely be required to be more than 600 characters anyway.

For a general overview of what a database view is, a web search will yield many sources of definitions and information. (Cue the obligatory wikipedia link: View (SQL) - Wikipedia).

PostgreSQL’s docs cover the specifics of their implementation starting at PostgreSQL: Documentation: 14: 3.2. Views. Also see PostgreSQL: Documentation: 14: Chapter 41. The Rule System

To directly answer your initial question - how do you modify a column that is also part of a view, you need to drop and re-create the view.