These are the queries from django 2.2 and django 3.1
2.2:
{'sql': 'SELECT ST_Union("__col1")::bytea FROM (SELECT DISTINCT "core_polymodel"."id" AS Col1, "core_polymodel"."name" AS Col2, "core_polymodel"."geom" AS Col3, "core_polymodel"."geom" AS "__col1" FROM "core_polymodel") subquery',
'time': '0.001'}
3.1
{'sql': 'SELECT ST_Union("__col1") FROM (SELECT DISTINCT "core_polymodel"."id" AS Col1, "core_polymodel"."name" AS Col2, "core_polymodel"."geom" AS Col3, "core_polymodel"."geom" AS "__col1" FROM "core_polymodel") subquery',
'time': '0.001'}
So it seems that the problem is the missing ::bytea casting