Converting an integer id field to Foreign Key field without data migration

Imagine a scenario, where there is a legacy model with a integer id field, however it is not a foreign key.

Below is an very simple example:

Of course it would be much better if the model is to be changed to this, where the car_id IntegerField becomes a  car  ForengnKey:

If we run makemigrations the files generated will look something like this:

If the wheel model/table contains data, then Django migration will ask for a default value to be specified. One way to get around this is to handcraft a migration, so a data migration will not be necessary:

The trick here is that we ‘pin’ the underlying column name with db_column before renaming the field.

I hope this will be useful!