Django change foreign keys to BigInt

Viewed 1363

I have two models (store and products) the primary key in both are BigInt but the relation column in products (store_id) is still integer. I dont want to use raw sql, how can I fix this issue using django?

Example:

class Product:
  id = models.BigAutoField(primary_key=True, editable=False)
  store = models.ForeignKey(
          to='stores.Store', on_delete=models.CASCADE
      )

class Store:
  id = models.BigAutoField(primary_key=True, editable=False)

store_id in model Products is still data type integer

1 Answers

You could remove default auto field and use BigAutoField instead by naming primary_key field

id = models.BigAutoField(primary_key=True)
Related