在models.py中创建数据库表
 

from django.db import models

# Create your models here.
class Book(models.Model):
name = models.CharField(max_length=20)
price = models.IntegerField
pub_date = models.DateField
 
 
 
在terminal中 :python manage.py makemigrations
 
返回结果:No changes detected
创建失败。
 
原因可能如下:
  1. migration folder You need a migrations package in your app.
  2. INSTALLED_APPS You need your app to be specified in the INSTALLED_APPS .dict
  3. Verbosity start by running makemigrations -v 3 for verbosity. This might shed some light on the problem.
  4. Full path In INSTALLED_APPS it is recommended to specify the full module app config path 'apply.apps.MyAppConfig'
  5. --settings you might want to make sure the correct settings file is set: manage.py makemigrations --settings mysite.settings
  6. specify app name explicitly put the app name in manage.py makemigrations myapp- that narrows down the migrations for the app alone and helps you isolate the problem.
  7. model meta check you have the right app_label in your model meta
  8. Debug django debug django core script. makemigrations command is pretty much straight forward. Here's how to do it in pycharm. change your script definition accordingly (ex: makemigrations --traceback myapp)
 
而我的情况是第二种 :setting.py内的INSTALLED_APPS未添加 app名字
 
 

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'app1',
]
 
添加上后,创建成功
 

django 创建model(数据库表)失败的更多相关文章

  1. django在admin后台注册自己创建的数据库表

    django在admin后台注册自己创建的数据库表,这样我们就可以在admin后台看到表结构信息,我们就可以在admin后台快速录入表记录信息 如果没有注册,那么你在登录django自带的admin的 ...

  2. iOS:CoreData数据库的使用一(创建单个数据库表)

    CoreData数据库框架:mac系统自带的数据库,它是苹果公司对sqlite进行封装而来的,既提供了对数据库的主要操作,也提供了具体的视图关系模型. 需要用到三个对象: 1•Managed Obje ...

  3. Hive中将文件加载到数据库表失败解决办法

    Hive中将文件加载到数据库表失败解决办法(hive创建表失败) 遇到的问题: FAILED: Execution Error, return code 1 from org.apache.hadoo ...

  4. 创建ASP.NET Core MVC应用程序(3)-基于Entity Framework Core(Code First)创建MySQL数据库表

    创建ASP.NET Core MVC应用程序(3)-基于Entity Framework Core(Code First)创建MySQL数据库表 创建数据模型类(POCO类) 在Models文件夹下添 ...

  5. Java创建Oracle数据库表

    我们通常只用java执行DML(即:insert, update, delete, select)操作,很少用来执行DDL(create, drop, alert)操作.今天试了下如何用java来创建 ...

  6. Django创建mysql数据表流程

    在Django项目建好后,在setting.py中设置好mysql连接参数: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysq ...

  7. django1.7取消syncdb后不能创建model相应表的问题

    一.在运行一个django程序时,无法创建自定义model相应的表. 我检查seetings.py文件,发现自定义的app,blog已经写到INSTALLED_APPS中, INSTALLED_APP ...

  8. 使用PowerDesigner创建mysql数据库表图

    使用PowerDesigner 建数据库表. 一直很忙,没有时间写东西.这次搞点会声会色的,嘿嘿 此技能为项目经理必备技能. 本次主角: 1.在workspace下建立一项目: physical da ...

  9. django创建model

    1.model实例 #!/usr/bin/python # coding:utf-8 from __future__ import unicode_literals from django.db im ...

随机推荐

  1. [物理学与PDEs]第4章第2节 反应流体力学方程组 2.1 粘性热传导反应流体力学方程组

    1.  记号: $Z=Z(t,{\bf x})$ 表示未燃气体在微团中所占的百分比 ($Z=1$ 表示完全未燃烧; $Z=0$ 表示完全燃烧). 2.  物理化学 (1)  燃烧过程中, 通过化学反应 ...

  2. Django REST Framework API Guide 06

    本节大纲 1.Validators 2.Authentication Validators 在REST框架中处理验证的大多数时间,您将仅仅依赖于缺省字段验证,或在序列化器或字段类上编写显式验证方法.但 ...

  3. 一篇文让你看懂NB-IoT、LoRa、eMTC、Sigfox及ZigBee的应用场景【转】

    转自:https://blog.csdn.net/nicholas_dlut/article/details/81051269

  4. Gulp实战

    推荐文章: gulp.js中文网   :     http://www.gulpjs.com.cn/ DBPOO           :   http://www.dbpoo.com/getting- ...

  5. 递归遍历所有xml的节点及子节点

    import java.io.File; import java.util.List; import org.dom4j.Attribute; import org.dom4j.Document; i ...

  6. 《剑指offer》第一个只出现一次的字符

    本题来自<剑指offer> 反转链表 题目: 思路: C++ Code: Python Code: 总结:

  7. Vue CLI 3+tinymce 5富文本编辑器整合

    基于Vue CLI 3脚手架搭建的项目整合tinymce 5富文本编辑器,vue cli 2版本及tinymce 4版本参考:https://blog.csdn.net/liub37/article/ ...

  8. django-admin.py startproject testdj 失败 没有工程文件夹

    今天第一次用django创建工程时一直没有反应,没有期望的文件夹出现 第一种:网上查找了一下,发现是因为py文件的默认打开不是python.exe,而是编辑器 解决方法:先随便找一个py文件,点击右键 ...

  9. apache 配置反向代理 设置

    1.下载 安装 下载地址:http://httpd.apache.org/download.cgi 将apache 安装到某个目录中 修改conf/http.conf文件 修改配置文件端口  (端口为 ...

  10. 微信小程序picker组件 - 省市二级联动

    picker 从底部弹起的滚动选择器,现支持五种选择器,通过mode来区分,分别是普通选择器,多列选择器,时间选择器,日期选择器,省市区选择器,默认是普通选择器. picker官方文档链接 由于项目需 ...