You are trying to add a non-nullable field 'id' to contact_info without a default

This happens when a different field was marked as primary key with primary_key=True earlier and you are removing that (in case of which django tries to add an id primary key).

That Django is asking for a default value for a primary key seems to be a bug.

To work around this problem, follow these steps:

  1. Supply a random default value when prompted during makemigrations.

  2. Go to the migration file generated (under your_app\migrations\ and delete the default=x,, x being the random value you supplied in step 1.

  3. While you are at the migration file, make sure the order of actions make sense (e.g., remove/alter one primary key before adding another). Save and close.

  4. Migrate as usual.


you could set `default="" and also editable=False.

E.g first_name = models.CharField(max_length=50, default="", editable=False).

Adding id field is unnecessary. Django will add it automatically.

Edit: Deleting the last migration files in your migrations folder and retry again. If it doesn't work, repeat the same process, you will know you have deleted the right file when your "makemigrations" command works.


Check Your Migration Files

./manage.py showmigrations <App Name>

[X] 0001_initial

[X] 0002_auto_20181204_1110

Revert Your Migrations Using

./manage.py migrate <App Name> <migration file name> eg: 0001_initial

or use zero (for complete migration revert) ./manage.py migrate <App Name> zero

Check Your Migrations

./manage.py showmigrations <App Name>

[ ] 0001_initial

[ ] 0002_auto_20181204_1110

Now delete all revert migrations and migrate again.

./manage.py migrate <App Name>