Reputation: 3586
I have an existing application written in Django and I am taking advantage of the models, migrations orm etc.
Each model has a column id
I was wondering if it is possible to rename this column to something else like person_id
I saw some examples creating new primary key columns but that is not what i want. I want to rename the existing id
column name
Upvotes: 4
Views: 4777
Reputation: 43300
You've said its not what you want but the answer is to make your own primary key,
From the docs,
If you’d like to specify a custom primary key, just specify primary_key=True on one of your fields. If Django sees you’ve explicitly set Field.primary_key, it won’t add the automatic id column.
Since it doesn't add the automatic id column, you've effectively renamed it
Upvotes: 8