1👍
Django doesn’t like it if you don’t have an integer PK field. I think it also runs into conflicts if the name of a ForeignKey
field is the same as its db_column
. In this case the legacy DB design makes it hard. In addition to the workaround you describe:
I think I may have “tricked” the system. what I did was create a new field called
tskmail = models.IntegerField(db_column='tskmail_id', primary_key=True)
and I removed theprimary_key=True
from the ForiegnKey so essentially I’m displaying the field twice.
I might try leaving tskmail_id
declared as an integer PK field and declare tskmail
as a ForeignKey
with db_column='tskmail_id'
(or leave db_column
unspecified so that default choice applies). It might be worth checking how Django implements subclassed non-abstract models – they might have a PK field that is also a FK to the parent table.