I have a OnetoOne field with primary_key=True in a model. Now I want to change that to a ForeignKey but cannot since there is no 'id'.
From this:
user = models.OneToOneField(User, primary_key=True, on_delete=models.CASCADE)
To this:
user1 = models.ForeignKey(User, related_name='questionnaire', on_delete=models.CASCADE)
Showing this while makemigrations:
You are trying to add a non-nullable field 'id' to historicaluserquestionnaire without a default; we can't do that (the database needs something to populate existing rows). Please select a fix: 1) Provide a one-off default now (will be set on all existing rows with a null value for this column) 2) Quit, and let me add a default in models.py
So how to do that? Thanks!