#8565 was closed as duplicate, but just so it is noted here, the default everywhere else in Django is to use object_id for the generic relation field name. It would make sense that comments used that instead of object_pk

My attachment just explicitly performs the correct casting. I am no Python expert, but this works for me (on posgresql). I think this is only a problem with new versions of psycopg, which are quite strict about types.

The commit message (though it cited the wrong ticket) stated the fix only applied to the specific problem noted here:

Fixed #8544: correctly cast Comment.object_pk to string when doing lookups. This really only papers over a bigger problem related to casting the RHS of GFKs, but that larger change can wait for a more systematic fix.

This problem is fixed. The larger problem needs its own ticket (if it doesn't have one already).