[Answer]-How to to retrieve the SQL type of the primary key of a related field mapped by Django's ORM

1👍

Try this for related fields:

ft = field.related_model._meta.pk.db_type(connection=connection)

model.pk is indeed a property that gets you the value of the pk for a model instance. model._meta.pk is the actual Field instance that is the primary key for that model.

👤knbk

Leave a comment