Ich bin nur eine einfache Befehl python manage.py makemigrationsSie versuchen, eine nicht-Nullable-Feld ‚id‘ hinzuzufügen, ohne eine Standard contact_info
jedoch mit, alles, was ich bekommen, ist dieser Fehler:
You are trying to add a non-nullable field 'id' to contact_info 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)
2) Quit, and let me add a default in models.py
Hier ist models.py:
class Document(models.Model):
docfile = models.FileField(upload_to='documents/')
class contact_number(models.Model):
contact_numbers= models.CharField(max_length=13)
class contact_address(models.Model):
address = models.CharField(max_length=100)
city = models.CharField(max_length=50)
state = models.CharField(max_length=50)
zip = models.CharField(max_length=5)
class contact_info(models.Model):
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
email = models.EmailField()
contact_numbers=models.ManyToManyField(contact_number)
addresses=models.ManyToManyField(contact_address)
Haben Sie den Fehler gelesen? Es ist sehr spezifisch. Was ist damit verwirrt? –
es ist spezifisch, aber ich weiß nicht, wie man das korrigiert oder Werte in db setzt. – shashank
Hatten Sie zuvor ein anderes Feld als Primärschlüssel festgelegt? Ich bin überrascht, dass die Migration versucht, ein ID-Feld hinzuzufügen. – Alasdair