我可以帮您翻译成中文。这段内容是关于编程的,作者正在尝试在他的项目中使用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:
我该怎么办?