Django 5.1.1 and view di MySQL

Hello everyone,
I am encountering an issue when accessing a MySQL view via an undeclared “Primary Key” field (cartid) in my models file. When I use get() or filter() on this field, the system raises an “Internal Server Error” and fails to retrieve any records.

Here is the relevant part of my models file:
class vCarrelPrinted(models.Model):
carrellostampatiid = models.IntegerField(db_column=‘CartPrintedID’, primary_key=True)
cartid = models.IntegerField(db_column=‘CartID’, blank=True, null=True)

However, if I reverse the declaration and make cartid the primary_key instead, everything works correctly:

class vCarrelPrinted(models.Model):
cartid = models.IntegerField(db_column=‘CartID’, primary_key=True)
carrellostampatiid = models.IntegerField(db_column=‘CartPrintedID’, blank=True, null=True)

This issue did not exist in Django 4.2.2, but appeared after upgrading to Django 5.1.1.

Could this be a bug in Django 5.1.1, or should MySQL views be declared differently in this version?

Thanks in advance!