出现 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':
cmdb\migrations\0001_initial.py
- Create model UserInfo

生成这个代表成功了

DjangoORM 执行 python manage.py makemigrations出现 no changes detected的更多相关文章

  1. 执行python manage.py makemigrations时报错TypeError: __init__() missing 1 required positional argument: 'on_delete'

    在执行python manage.py makemigrations时报错: TypeError: __init__() missing 1 required positional argument: ...

  2. Django :执行 python manage.py makemigrations 时报错 TypeError: __init__() missing 1 required positional argument: 'on_delete'

    原因 执行命令 python manage.py makemigrations 报错 TypeError: __init__() missing 1 required positional argum ...

  3. django 执行 python manage.py makemigrations 报错

    RuntimeError: Model class app_anme.models.xxx doesn't declare an explicit app_label and isn't in an ...

  4. 执行: python manage.py makemigrations报AttributeError: 'str' object has no attribute 'decode'

    找到错误代码(line146):query = query.encode(errors='replace') 解决方法:把decode改为encode即可.

  5. Django 中 python manage.py makemigrations 与 python manage.py migrate

    执行 python manage.py makemigrations django根据settings.py里面的INSTALLED_APPS项设置找到对应app里的models.py,应用里面创建的 ...

  6. Django orm 中 python manage.py makemigrations 和 python manage.py migrate 这两条命令用途

    生成一个临时文件 python manage.py makemigrations 这时其实是在该app下建立 migrations目录,并记录下你所有的关于modes.py的改动,比如0001_ini ...

  7. 【Django2.0】python manage.py makemigrations 和 python manage.py migrate的区别

    无论当我们第一次在models.py中创建类对象还是对类中的属性进行修改,我们都会使用python manage.py makemigrations 和 python manage.py migrat ...

  8. 【解决方案】django初始化执行python manage.py migrate命令后,除default数据库之外的其他数据库中的表没有创建出来

    [问题原因]:django工程中存在多个应用,每个应用都指定了对应的数据库.执行python manage.py migrate命令时没有指定数据库,将只初始化默认的default数据库. [解决方案 ...

  9. python manage.py makemigrations生成数据变化的问题

    今天遇到的生成数据库的问题django生成数据库的话,使用的是两条命令,一个是python manage.py makemigrations,以及python manage.py migrate在设计 ...

随机推荐

  1. maven配置nexus

    setting配置: <?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the ...

  2. sama5d36 can0 can1 测试

    1 删除/bin/ip 保留/sbin/ip 2 ip link set can0 type can bitrate 125000 ip link set can1 type can bitrate ...

  3. API - 使用数据仓库 - 基础篇

    数据仓库是集成在Spider Studio中的一个重要功能, 利用它可以非常方便的保存采集到的数据, 然后导出或者在其他脚本中再利用. 数据仓库的全部功能都集成在DataManager这个静态类里面, ...

  4. 0810 smarty

    1.Smarty简介(why,what) why:smarrty 将前端工程师和程序员的工作分开,让前端工程师完成前台页面的工作,程序员完成后台的业务逻辑.what模版引擎是用来将PHP代码和模版页组 ...

  5. 常用gitignore模板

    作用是让临时文件和中间文件都不提交到代码库中 工程相关的.gitignore 放在根目录 常用 的有: Android.gitignore C++.gitignore C.gitignore CMak ...

  6. node.js发http请求

    标准库中默认的HTTP模块 const https = require('https'); https.get('https://api.nasa.gov/planetary/apod?api_key ...

  7. 情商 EQ & 儿童情商

    EQ 包括哪些内容 1. 认知自身情绪的能力(正确客观的评价自己)2. 管理自己情绪的能力(控制冲动) 3. 自我激励能力(学会抗挫折) 4. 认识他人情绪的能力(学会移情) 5. 人际关系处理能力 ...

  8. 使用asp.net调用谷歌地图api

    <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> ...

  9. erlang-sunface的博客地址

    erlang-sunface的博客地址: http://blog.csdn.net/abv123456789/article/category/2206185

  10. LoadRunner学习---脚本编写(4)(比较重要)

    今天接着来翻译http://www.wilsonmar.com/中关于LoadRunner脚本编写部分,下面该翻译脚本编写中一些比较重要的部分了. Web用户Action 在VuGen中,脚本产生的默 ...