CommandError: App 'books' has migrations

执行python manage.py sql polls时出现错误

?
1
2
E:\projects\djangotest\mysite>python manage.py sql polls
CommandError: App  'polls'  has migrations. Only the sqlmigrate and sqlflush commands can be used when an app has migrations.

处理:

删除migrations目录或者执行manage.py migrate

参考:http://stackoverflow.com/questions/24215005/django-commanderror-app-polls-has-migrations

------------------------------------------------------------------------------------------------------

The problem is that you are using Django 1.8 while going through 1.6 tutorial. Pay attention to the first words at the beginning of thetutorial:

This tutorial is written for Django 1.6 and Python 2.x. If the Django version doesn’t match, you can refer to the tutorial for your version of Django by using the version switcher at the bottom right corner of this page, or update Django to the newest version.

In your case, either downgrade to 1.6, or use the tutorial for the development (currently 1.8) version.(https://docs.djangoproject.com/en/dev/intro/tutorial02/)

--------------------------------------------------------------------------------------------------------

删除books目录下的migrations文件夹后成功,结果如下:

[root@localhost mysite]# python manage.py sqlall books
BEGIN;
CREATE TABLE `books_publisher` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `name` varchar(30) NOT NULL,
    `address` varchar(100) NOT NULL,
    `city` varchar(50) NOT NULL,
    `state_province` varchar(50) NOT NULL,
    `county` varchar(30) NOT NULL,
    `web` varchar(200) NOT NULL
)
;
CREATE TABLE `books_author` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `first_name` varchar(50) NOT NULL,
    `last_name` varchar(50) NOT NULL,
    `email` varchar(254) NOT NULL
)
;
CREATE TABLE `books_books` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `title` varchar(30) NOT NULL,
    `author` varchar(30) NOT NULL,
    `publisher` varchar(50) NOT NULL,
    `publish_date` date NOT NULL
)
;

COMMIT;


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值