python manage.py makemigrations生成数据变化的问题
今天遇到的生成数据库的问题
django生成数据库的话,使用的是两条命令,一个是python manage.py makemigrations,以及python manage.py migrate
在设计数据库表的时候,一定要搞清楚表和表之间的关系,因为表和表之间有依赖,必须是首先生成A表,才能再生成B表
每一个注册过的app下面都有一个makemigrations的文件夹,这个文件夹里面的文件就是记录数据表的迁移和变化的,如果是
正常情况下使用命令生成的话,也是django自行按照顺序生成的迁移文件,不会有什么问题。而我现在的情况是,项目里面
app下面的makemigrations文件夹被人删掉了,只能自己去生成,但是单独使用上述的命令又会因为表结构的问题而出错,所以
只能根据表生成的先后顺序使用python manage.py makemigrations app名字 一个一个的去生成这个文件夹,然后再使用
python manage.py migrate app名字 一个一个去实现表的变化,生成变化后的表
所以在编程的过程中,不论遇到什么当时不可以解决的问题,都要保持心态,搞清楚原理,再对症下药,当然不耻下问也很重要
还有,有些人喜欢装逼,请不要理他,装逼的人自有天收,我听着就好了,don't care
python manage.py makemigrations生成数据变化的问题的更多相关文章
- 【Django2.0】python manage.py makemigrations 和 python manage.py migrate的区别
无论当我们第一次在models.py中创建类对象还是对类中的属性进行修改,我们都会使用python manage.py makemigrations 和 python manage.py migrat ...
- Django 中 python manage.py makemigrations 与 python manage.py migrate
执行 python manage.py makemigrations django根据settings.py里面的INSTALLED_APPS项设置找到对应app里的models.py,应用里面创建的 ...
- Django orm 中 python manage.py makemigrations 和 python manage.py migrate 这两条命令用途
生成一个临时文件 python manage.py makemigrations 这时其实是在该app下建立 migrations目录,并记录下你所有的关于modes.py的改动,比如0001_ini ...
- $ python manage.py makemigrations You are trying to add a non-nullable field 'name' to course without a default; we can't do that (the database needs something to populate existing rows). Please selec
问题: $ python manage.py makemigrationsYou are trying to add a non-nullable field 'name' to course wit ...
- DjangoORM 执行 python manage.py makemigrations出现 no changes detected
出现 no changes detected python manage.py makemigrations No changes detected 为什么出现这种情况: 当执行这条命令,他会去找所有 ...
- python学习-- 数据库迁移 python manage.py makemigrations 和 python manage.py migrate
python manage.py makemigrations 和 python manage.py migrate
- 执行python manage.py makemigrations时报错TypeError: __init__() missing 1 required positional argument: 'on_delete'
在执行python manage.py makemigrations时报错: TypeError: __init__() missing 1 required positional argument: ...
- 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 ...
- django 执行 python manage.py makemigrations 报错
RuntimeError: Model class app_anme.models.xxx doesn't declare an explicit app_label and isn't in an ...
随机推荐
- ASP.NET MVC 处理404与500错误页面的方法
第一步创建ErrorPageController 第二步添加Oops页面 @{ ViewBag.Title = "Oops"; Layout = "~/Areas/Adm ...
- 20145235李涛《网络对抗》Exp5 MSF基础应用
基础问答 用自己的话解释什么是exploit,payload,encode? exploit:相当于搬运工,把攻击代码传送到靶机中. payload:相当于shellcode. encode:相当于包 ...
- [翻译]PostCSS简介
许多开发人员花时间在使用CSS的预处理器上如less,sass和stylus.这些工具已经成为Web开发的重要组成部分.写一个网站的样式,不使用嵌套,变量或混入等功能很少见.它们每个都是非常实用的,让 ...
- mysql DATE_FORMAT 年月日时分秒格式化
SELECT DATE_FORMAT(NOW(),'%Y-%m-%d %H:%i:%s')
- C# 打开电子邮件软件
使用客户端打开指定的URL 使用Process.Start方法可以在浏览器打开指定的URL.代码如下所示. [C#] //使用客户端打开“http://www.baidu.com” System.Di ...
- spring boot项目获取application配置文件参数的两种方式
前言:了解过spring boot这个技术的,应该知道spring boot的核心配置文件application.properties,当然也可以通过注解自定义配置文件**.properties的信息 ...
- python函数式编程之高阶函数学习
基本概念 函数式编程,是一种抽象程度很高的编程范式,纯粹的函数式编程语言编写的函数没有变量.因此,任意一个函数,只要输入确定,输出就确定的这种函数我们称之为纯函数,我们称这种函数没有副作用.而允许使用 ...
- pipenv安装库使用国内镜像
pipenv install django超级慢,卡住不动,最后不得不CTRL+C中止 这时有必要改成国内源了,打开Pipfile文件,发现内容是: [[source]] verify_ssl = t ...
- IOS-视频
一.简介 iOS提供了MPMoviePlayerController.MPMoviePlayerViewController两个类,可以用来轻松播放视频和网络流媒体\网络音频 提示:网络音频同样使用此 ...
- 《The Cg Tutorial》阅读笔记——环境贴图 Environment Mapping
本文为大便一箩筐的原创内容,转载请注明出处,谢谢:http://www.cnblogs.com/dbylk/p/4969956.html 环境贴图 Environment Mapping 一.简介 环 ...