• DjangoORM 执行 python manage.py makemigrations出现 no changes detected


    出现 no changes detected

    python manage.py makemigrations
    No changes detected

    为什么出现这种情况:

    当执行这条命令,他会去找所有models,在数据库生成表 

    因为有时候app项目多的时候,他就不知道找哪个models了,不知道在哪个models生成数据库表

     

    这里有models.py 

    需要要django setting配置文件 这里加上 app项目名字  例如 cmdb

    那django就会去cmdb项目下 找models.py 生成数据库

    INSTALLED_APPS = [
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        'cmdb',
    ]


    再执行 python manage.py makemigrations

    可以了

    python manage.py makemigrations
    Migrations for 'cmdb':
      cmdbmigrations001_initial.py
        - Create model UserInfo

    生成这个代表成功了

  • 相关阅读:
    mysql 主从服务器配置
    Linux命令
    Kali
    Python进阶
    性能测试工具
    sphinx搜索
    页面静态化
    PHP API接口
    线程的生命周期
    多线程的创建
  • 原文地址:https://www.cnblogs.com/mingerlcm/p/9983348.html
Copyright © 2020-2023  润新知