[Django] #37208: db_persist has problem with postgres

3 views
Skip to first unread message

Django

unread,
Jul 8, 2026, 3:56:12 AM (yesterday) Jul 8
to django-...@googlegroups.com
#37208: db_persist has problem with postgres
-------------------------------------+-------------------------------------
Reporter: twili | Type: Bug
Status: new | Component: Database
| layer (models, ORM)
Version: 6.0 | Severity: Normal
Keywords: db_persist, | Triage Stage:
GeneratedField | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
== Environment:
Python version: 3.13.3
Django version: 6.0.7
psycopg version: 3.2.12
Postgres version: 18.1

----


== Explain the bug:
Here is my code:


{{{
tmp = models.GeneratedField(
db_persist=False, # In here, I've set the column type as virtual
expression=models.Q(standard_symbol_tmp__isnull=False),
null=True,
output_field=models.BooleanField(),
)
}}}
And when I do `makemigrations` all things are good, but on **migrating**,
django says:


{{{
SystemCheckError: System check identified some issues:

ERRORS:
symbol.Symbol.tmp: (fields.E221) PostgreSQL does not support non-persisted
GeneratedFields.
HINT: Set db_persist=True on the field.

}}}

While I know that Postgres supports the `VIRTUAL` and `STORED` generated
columns, here is the postgres release note ref:
[https://www.postgresql.org/about/news/postgresql-18-released-3142/]

While the migration file is created and is like:
{{{
class Migration(migrations.Migration):

# ...rest of the code ...

operations = [
migrations.AddField(
model_name="symbol",
name="tmp",
field=models.GeneratedField(
db_persist=False,
expression=models.Q(("standard_symbol_tmp__isnull",
False)),
null=True,
output_field=models.BooleanField(),
),
),
]

}}}


And when I set `db_persist` to `True` AND DO NOT TOUCH THE migration file
and migrate, all things are good, column creates as VIRTUAL in postgres,
NOT STORED.
--
Ticket URL: <https://code.djangoproject.com/ticket/37208>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jul 8, 2026, 3:59:15 AM (yesterday) Jul 8
to django-...@googlegroups.com
#37208: db_persist has problem with postgres
-------------------------------------+-------------------------------------
Reporter: twili | Owner: (none)
Type: Bug | Status: new
Component: Database layer | Version: 6.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: db_persist, | Triage Stage:
GeneratedField | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by twili):

== A quick fix
I didn't changed the migration file, keep that as like:
{{{
operations = [
migrations.AddField(
model_name="symbol",
name="tmp",
field=models.GeneratedField(
db_persist=False, # 👈 NOTE, this hasn't changed
expression=models.Q(("standard_symbol_tmp__isnull",
False)),
null=True,
output_field=models.BooleanField(),
),
),
]
}}}

And changed the model and set `db_persist=True`, then DID NOT create new
migration file, then all things worked.
I know I could also do a fake migration too.
--
Ticket URL: <https://code.djangoproject.com/ticket/37208#comment:1>

Django

unread,
Jul 8, 2026, 7:33:36 AM (23 hours ago) Jul 8
to django-...@googlegroups.com
#37208: db_persist has problem with postgres
-------------------------------------+-------------------------------------
Reporter: Twili Spar | Owner: (none)
Type: Bug | Status: closed
Component: Database layer | Version: 6.0
(models, ORM) |
Severity: Normal | Resolution: duplicate
Keywords: db_persist, | Triage Stage:
GeneratedField | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

* resolution: => duplicate
* status: new => closed

Comment:

See #36277 (e8190b370e508648b0f0ee9b86876f97d3997e14) which added support
for `GeneratedField(db_persist=False)` on Postgres 18+ to Django 6.1
(still in it's first beta).

Your choices here are to either

1. [https://docs.djangoproject.com/en/6.0/ref/settings/#silenced-system-
checks Silence the check] until you upgrade to Django 6.1
2. Upgrade to Django `6.1b1`
--
Ticket URL: <https://code.djangoproject.com/ticket/37208#comment:2>
Reply all
Reply to author
Forward
0 new messages