Django,makemigrations 不检测模型更改

时间:2021-04-12 10:35:02

标签: python django

我正在学习 Django,我正在使用本教程:

https://www.youtube.com/watch?v=F5mRW0jo-U4&t=912s

我创建了一个名为 products 的应用程序,并将它保存在 INSTALLED_APPS 中。

在产品应用文件夹的 Product 文件中创建 models.py 类后,我创建了一些字段,例如 price

但是,当我尝试使用 makemigrations 命令时,未报告检测到任何更改。

文件夹布局和设置

folder layout and settings

models.py

from django.db import models

# Create your models here.
class Product(models.Model):
    title = models.TextField()
    description = models.TextField()
    price = models.TextField()

我检查了 Product 类是否有任何问题,但就我所见似乎没有任何问题,所以我不知道为什么没有检测到任何变化。

>

2 个答案:

答案 0 :(得分:0)

15

您可能删除了应用内的迁移文件夹或 /migrations/ 文件夹内的 init.py,创建一个新的

<块引用>

我的项目/应用程序/ 我的应用程序/ 迁移/ init.py

你总是可以单独做 makemigrations 而不做上面的步骤

python manage.py makemigrations myapp

答案 1 :(得分:-1)

参考表 - djangomigrations .. 如果表中已经存在 makemigration 文件的条目,则 trunckage 并重新运行 makemigrations,然后执行迁移

相关问题