python - Django 迁移 : doesn't create tables

标签 python mysql django migration

在一些错误之后,我删除了我的数据库,删除了所有迁移文件(我离开了 init.py)。 现在,当我运行时

python migrate.py makemigrations   // It creates migrations correctly
python migrate.py migrate          // It outputs "app.0001_initial OK"

但绝对NO table(与我的应用相关)是创建的。只有那些与 django 相关的。 并且在迁移表中,我的应用程序迁移被标记为已完成但没有创建表,就像我说的那样,非常不愉快。

这是我的迁移文件的摘录:

# -*- coding: utf-8 -*-
# Generated by Django 1.9 on 2016-02-18 21:59
from __future__ import unicode_literals

import colorful.fields
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='Client',
            fields=[
                ('id', models.AutoField(db_column='idtblclients', primary_key=True, serialize=False)),
                ('genre1', models.CharField(blank=True, max_length=10)),
            ('prenom1', models.CharField(blank=True, max_length=45)),
            ('nom1', models.CharField(blank=True, max_length=45)),
            ('genre2', models.CharField(blank=True, max_length=10)),
            ('prenom2', models.CharField(blank=True, max_length=45)),
            ('nom2', models.CharField(blank=True, max_length=45)),
            ('courriel', models.CharField(blank=True, max_length=45)),
            ('langue', models.CharField(blank=True, max_length=1)),
            ('numtel1', models.CharField(blank=True, db_column='NumTel1', max_length=20)),
            ('numtel2', models.CharField(blank=True, db_column='NumTel2', max_length=20)),
            ('numcivique', models.CharField(blank=True, db_column='NumCivique', max_length=15)),
            ('rue', models.CharField(blank=True, db_column='Rue', max_length=45)),
            ('ville', models.CharField(blank=True, db_column='Ville', max_length=45)),
            ('codepostal', models.CharField(blank=True, db_column='CodePostal', max_length=45)),
            ('timestamp', models.DateTimeField(blank=True, db_column='Timestamp', null=True)),
            ('zone', models.CharField(blank=True, db_column='Zone', max_length=45)),
        ],
        options={
            'db_table': 'tblclients',
            'managed': False,
        },
    ),
....

你知道如何解决它吗?

最佳答案

python manage.py migrate --fake APPNAME zero

这将使您的迁移变得虚假。 现在你可以运行迁移脚本了

python manage.py migrate APPNAME

将创建表 你解决了你的问题..干杯!!!

关于python - Django 迁移 : doesn't create tables,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35494035/

相关文章:

java - 从数据库中获取最后一个索引的重复数据,而不是 Java 中的所有数据

jquery - Django/jQuery - 自动完成和动态更新表单字段值

python - Django:带有 mixins 和调度方法的基于类的 View

python - 有没有办法将 sqlalchemy 查询中的数据附加到 for 循环内的 pandas 数据框中?

python - 在openCV和NumPy中使用查找表

Python:在字典中查找具有唯一值的键?

mysql - 使用两个左连接返回重复的 mysql 结果

mysql - nodejs/socket.io 与 node-mysql |安全困惑

python - 将大量 XML 数据导入 Google App Engine

javascript - 如何在 Django 服务器提供的 Eclipse 中调试 javascript