我试图让 mptt 与我当前的项目一起工作,但在数据库迁移方面存在问题。
这是我的模型
from django.db import models
from mptt.models import MPTTModel, TreeForeignKey
class Section(MPTTModel):
name = models.CharField(max_length=50, unique=True)
parent = TreeForeignKey('self', null=True, blank=True, related_name='children', db_index=True)
class MPTTMeta:
order_insertion_by = ['name']
我在命令行中运行它:
sudo python manage.py makemigrations core
但似乎正在获取与级别字段相关的错误
You are trying to add a non-nullable field 'level' to section 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
Select an option:
我应该怎么办?