【发布时间】:2021-04-06 18:18:35
【问题描述】:
我在 Django 中为帖子创建了一个模型,我正在尝试更新数据库 (MySQL) 中的一个字段。 我有以下代码块: 模型.py
class Post (models.Model):
title = models.CharField()
preamble = models.CharField()
body = models.TextField ()
createdAt = models.DateTimeField(auto_now_add=True, blank=True)
我想添加另一个名为 author author=models.ForeignKey(User, on_delete=models.CASCADE 的字段
另外,我想将其中一个字段的名称从preamble 更改为introduction
每当我运行命令python manage.py makemigrations 和python manage.py migrate 时,我都会收到一个终止迁移过程的错误。它告诉我我的数据库中的字段preamble 无法识别。是否可以将preamble 更新为introduction?
【问题讨论】:
标签: python django django-models field mysql-python