I have an Employee model in my django app like the following:
class Employee(models.Model):
role_choices = (('CRUD', 'CRUD'), ('View', 'View'))
user = models.OneToOneField(User, on_delete=models.CASCADE, primary_key=True)
company = models.ForeignKey(Company, on_delete=models.CASCADE, related_name="company")
name = models.CharField(max_length=500, default=0)
email = models.EmailField(max_length=500, default=0)
phone = models.CharField(max_length=500, default=0)
city = models.CharField(max_length=500, default=0)
But now I want to remove this user field but since it's primaryKey it is asking me to do this:
You are trying to add a non-nullable field 'id' to employee 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
Select an option:
providing a value will result in an error since there is no point in giving a single id as default value. How to solve this ?