【发布时间】:2019-12-12 18:03:26
【问题描述】:
我有两个他们喜欢的模型类:
from django.db import models
from django.urls import reverse
class Place(models.Model):
address = models.CharField(max_length=80)
class Author(Place):
name = models.CharField(max_length=50)
但是当我想执行 makemigartions 时,django 会在下面显示错误:
You are trying to add a non-nullable field 'place_ptr' to author 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:
我在 Author 表中有一些数据,但我不想删除这些数据。
有没有人可以帮帮我?
【问题讨论】:
标签: python django django-models