Django:尝试执行迁移时未处理的挂起操作

2024-06-02 10:55:37 发布

您现在位置:Python中文网/ 问答频道 /正文

当尝试将迁移应用于Django 1.9.1项目时,我得到:

ValueError: Unhandled pending operations for models:
  casos.caso (referred to by fields: oferta.Columna.casos, oferta.Columna_casos.caso, oferta.Producto.banners_casos, oferta.Producto.casos_de_exito, oferta.Producto_banners_casos.caso, oferta.Producto_casos_de_exito.caso)

项目运行正常,没有错误。 我已经成功地将所有迁移应用到“casos”和“oferta”,这在我在其他应用程序上运行migrate时会显示出来。在

这是我从django1.4更新的遗留项目。我在“oferta”和“casos”之间遇到了一个循环迁移依赖问题,我通过将对“oferta”的引用移动到“casos”中的第二个迁移来解决这个问题。在

要执行的完整回溯和迁移:

^{pr2}$

casos/migrations/0001.py

# -*- coding: utf-8 -*-
# Generated by Django 1.9.1 on 2016-01-25 11:30
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion
import tinymce.models


class Migration(migrations.Migration):
    initial = True
    operations = []

casos/migrations/0002.py

# -*- coding: utf-8 -*-
# Generated by Django 1.9.1 on 2016-01-25 11:38
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion
import tinymce.models


class Migration(migrations.Migration):
    dependencies = [
        ('casos', '0001_initial'),
        ('productos_y_servicios', '__first__'),
        ('tags', '__first__'),
        ('sonda_core', '0001_initial'),
        ('noticias', '0001_initial'),
        ('industrias', '__first__'),
        ('oferta', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
                name='Caso',
                fields=[
                    ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                    ('visible', models.BooleanField(default=True)),
                    ('en_portada', models.NullBooleanField(default=False,
                                                           help_text=b'Solo un caso podr\xc3\xa1 aparecer en portada')),
                    ('titulo', models.CharField(max_length=200)),
                    ('titulo_es', models.CharField(max_length=200, null=True)),
                    ('titulo_en', models.CharField(max_length=200, null=True)),
                    ('bajada', tinymce.models.HTMLField()),
                    ('bajada_es', tinymce.models.HTMLField(null=True)),
                    ('bajada_en', tinymce.models.HTMLField(null=True)),
                    ('bajada_nueva', tinymce.models.HTMLField(blank=True)),
                    ('bajada_nueva_es', tinymce.models.HTMLField(blank=True, null=True)),
                    ('bajada_nueva_en', tinymce.models.HTMLField(blank=True, null=True)),
                    ('cliente', models.CharField(max_length=200)),
                    ('cliente_es', models.CharField(max_length=200, null=True)),
                    ('cliente_en', models.CharField(max_length=200, null=True)),
                    ('solucion', models.CharField(max_length=200)),
                    ('solucion_es', models.CharField(max_length=200, null=True)),
                    ('solucion_en', models.CharField(max_length=200, null=True)),
                    ('highlights', tinymce.models.HTMLField()),
                    ('highlights_es', tinymce.models.HTMLField(null=True)),
                    ('highlights_en', tinymce.models.HTMLField(null=True)),
                    ('video', models.FileField(blank=True, upload_to=b'casos/videos')),
                    ('video_youtube', models.TextField(blank=True, max_length=500)),
                    ('titulo_video', models.CharField(blank=True, max_length=200)),
                    ('titulo_video_es', models.CharField(blank=True, max_length=200, null=True)),
                    ('titulo_video_en', models.CharField(blank=True, max_length=200, null=True)),
                    ('imagen_principal', models.ImageField(upload_to=b'casos/imagen')),
                    ('fecha', models.DateField(auto_now_add=True)),
                    ('resumen', tinymce.models.HTMLField(blank=True)),
                    ('resumen_es', tinymce.models.HTMLField(blank=True, null=True)),
                    ('resumen_en', tinymce.models.HTMLField(blank=True, null=True)),
                    ('perfil', tinymce.models.HTMLField(blank=True, verbose_name=b'perfil cliente')),
                    ('perfil_es', tinymce.models.HTMLField(blank=True, null=True, verbose_name=b'perfil cliente')),
                    ('perfil_en', tinymce.models.HTMLField(blank=True, null=True, verbose_name=b'perfil cliente')),
                    ('necesidades', tinymce.models.HTMLField(blank=True, verbose_name=b'necesidades de negocio')),
                    ('necesidades_es',
                     tinymce.models.HTMLField(blank=True, null=True, verbose_name=b'necesidades de negocio')),
                    ('necesidades_en',
                     tinymce.models.HTMLField(blank=True, null=True, verbose_name=b'necesidades de negocio')),
                    ('imagen_necesidades', models.ImageField(blank=True, upload_to=b'uploads/casos')),
                    ('beneficios', tinymce.models.HTMLField(blank=True)),
                    ('beneficios_es', tinymce.models.HTMLField(blank=True, null=True)),
                    ('beneficios_en', tinymce.models.HTMLField(blank=True, null=True)),
                    ('testimonios', tinymce.models.HTMLField(blank=True)),
                    ('testimonios_es', tinymce.models.HTMLField(blank=True, null=True)),
                    ('testimonios_en', tinymce.models.HTMLField(blank=True, null=True)),
                    ('imagen_testimonios', models.ImageField(blank=True, upload_to=b'uploads/casos')),
                    ('solucion_nueva', tinymce.models.HTMLField(blank=True)),
                    ('solucion_nueva_es', tinymce.models.HTMLField(blank=True, null=True)),
                    ('solucion_nueva_en', tinymce.models.HTMLField(blank=True, null=True)),
                    ('resultados', tinymce.models.HTMLField(blank=True)),
                    ('resultados_es', tinymce.models.HTMLField(blank=True, null=True)),
                    ('resultados_en', tinymce.models.HTMLField(blank=True, null=True)),
                    ('casos_relacionados',
                     models.ManyToManyField(blank=True, related_name='_caso_casos_relacionados_+', to='casos.Caso')),
                    ('industrias', models.ManyToManyField(blank=True, to='industrias.Industria')),
                ],
                options={
                    'ordering': ['-fecha'],
                    'verbose_name': 'Caso de \xc9xito',
                    'verbose_name_plural': 'Casos de \xc9xito',
                },
        ),
        migrations.CreateModel(
                name='Descarga',
                fields=[
                    ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                    ('archivo', models.FileField(upload_to=b'casos/descargas')),
                    ('nombre', models.CharField(max_length=200)),
                    ('caso', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='casos.Caso')),
                ],
                options={
                    'ordering': ['nombre'],
                },
        ),
        migrations.CreateModel(
                name='Linea',
                fields=[
                    ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                    ('nombre', models.CharField(blank=True, max_length=200)),
                ],
        ),
        migrations.AddField(
                model_name='caso',
                name='linea_de_negocios',
                field=models.ManyToManyField(blank=True, to='casos.Linea'),
        ),
        migrations.AddField(
                model_name='caso',
                name='noticias_relacionadas',
                field=models.ManyToManyField(blank=True, to='noticias.Noticia'),
        ),
        migrations.AddField(
                model_name='caso',
                name='oferta_relacionada',
                field=models.ManyToManyField(blank=True, related_name='casos', to='oferta.Producto'),
        ),
        migrations.AddField(
                model_name='caso',
                name='paises',
                field=models.ManyToManyField(blank=True,
                                             help_text=b'Opcional. Si no se elige nada aparecer\xc3\xa1 en todos los paises.',
                                             to='sonda_core.Pais'),
        ),
        migrations.AddField(
                model_name='caso',
                name='productos',
                field=models.ManyToManyField(blank=True, editable=False, to='productos_y_servicios.Producto'),
        ),
        migrations.AddField(
                model_name='caso',
                name='solucion_productos',
                field=models.ManyToManyField(blank=True, related_name='CasosSolucion', to='oferta.Producto'),
        ),
        migrations.AddField(
                model_name='caso',
                name='solucion_subcats',
                field=models.ManyToManyField(blank=True, related_name='CasosSolucion', to='oferta.SubCategoria',
                                             verbose_name=b'Solucion Subcategorias'),
        ),
        migrations.AddField(
                model_name='caso',
                name='subcategorias',
                field=models.ManyToManyField(blank=True, editable=False, to='productos_y_servicios.SubCategoria'),
        ),
        migrations.AddField(
                model_name='caso',
                name='subcategorias_relacionadas',
                field=models.ManyToManyField(blank=True, related_name='CasosRelacionados', to='oferta.SubCategoria'),
        ),
        migrations.AddField(
                model_name='caso',
                name='tags',
                field=models.ManyToManyField(blank=True, to='tags.Tag'),
        ),
    ]

oferta/migrations/0003.py(oferta中唯一引用casos的迁移)

# -*- coding: utf-8 -*-
# Generated by Django 1.9.1 on 2016-01-26 16:12
from __future__ import unicode_literals

from django.db import migrations, models
import tinymce.models


class Migration(migrations.Migration):

    dependencies = [
        ('oferta', '0002_auto_20160125_1143'),
    ]

    operations = [
        migrations.AlterField(
            model_name='producto',
            name='aparece_en_portada',
            field=models.BooleanField(default=True, editable=False),
        ),
        migrations.AlterField(
            model_name='producto',
            name='banner_large',
            field=models.ImageField(blank=True, help_text=b'2000x587', null=True, upload_to=b'oferta', verbose_name=b'banner grande'),
        ),
        migrations.AlterField(
            model_name='producto',
            name='banner_small',
            field=models.ImageField(blank=True, help_text=b'968x586', null=True, upload_to=b'oferta', verbose_name=b'banner chico'),
        ),
        migrations.AlterField(
            model_name='producto',
            name='banners_casos',
            field=models.ManyToManyField(blank=True, editable=False, related_name='productos_oferta_banners', to='casos.Caso'),
        ),
        migrations.AlterField(
            model_name='producto',
            name='banners_noticias',
            field=models.ManyToManyField(blank=True, editable=False, related_name='productos_oferta_banners', to='noticias.Noticia'),
        ),
        migrations.AlterField(
            model_name='producto',
            name='banners_ofertas',
            field=models.ManyToManyField(blank=True, editable=False, related_name='_producto_banners_ofertas_+', to='oferta.Producto'),
        ),
        migrations.AlterField(
            model_name='producto',
            name='icono',
            field=models.ImageField(blank=True, editable=False, null=True, upload_to=b'upload/producto'),
        ),
        migrations.AlterField(
            model_name='producto',
            name='productos_bajada',
            field=tinymce.models.HTMLField(blank=True, editable=False),
        ),
        migrations.AlterField(
            model_name='producto',
            name='productos_bajada_en',
            field=tinymce.models.HTMLField(blank=True, editable=False, null=True),
        ),
        migrations.AlterField(
            model_name='producto',
            name='productos_bajada_es',
            field=tinymce.models.HTMLField(blank=True, editable=False, null=True),
        ),
        migrations.AlterField(
            model_name='producto',
            name='resumen_bajada',
            field=tinymce.models.HTMLField(blank=True, editable=False),
        ),
        migrations.AlterField(
            model_name='producto',
            name='resumen_bajada_en',
            field=tinymce.models.HTMLField(blank=True, editable=False, null=True),
        ),
        migrations.AlterField(
            model_name='producto',
            name='resumen_bajada_es',
            field=tinymce.models.HTMLField(blank=True, editable=False, null=True),
        ),
        migrations.AlterField(
            model_name='producto',
            name='resumen_cuerpo',
            field=tinymce.models.HTMLField(blank=True, editable=False),
        ),
        migrations.AlterField(
            model_name='producto',
            name='resumen_cuerpo_en',
            field=tinymce.models.HTMLField(blank=True, editable=False, null=True),
        ),
        migrations.AlterField(
            model_name='producto',
            name='resumen_cuerpo_es',
            field=tinymce.models.HTMLField(blank=True, editable=False, null=True),
        ),
        migrations.AlterField(
            model_name='producto',
            name='titulo_valores',
            field=models.CharField(default=b'Valor para su negocio', editable=False, max_length=500),
        ),
        migrations.AlterField(
            model_name='producto',
            name='titulo_valores_en',
            field=models.CharField(default=b'Valor para su negocio', editable=False, max_length=500, null=True),
        ),
        migrations.AlterField(
            model_name='producto',
            name='titulo_valores_es',
            field=models.CharField(default=b'Valor para su negocio', editable=False, max_length=500, null=True),
        ),
        migrations.AlterField(
            model_name='producto',
            name='titulo_ventajas',
            field=models.CharField(default=b'Servicios con mirada integral y estructura modular', editable=False, max_length=500),
        ),
        migrations.AlterField(
            model_name='producto',
            name='titulo_ventajas_en',
            field=models.CharField(default=b'Servicios con mirada integral y estructura modular', editable=False, max_length=500, null=True),
        ),
        migrations.AlterField(
            model_name='producto',
            name='titulo_ventajas_es',
            field=models.CharField(default=b'Servicios con mirada integral y estructura modular', editable=False, max_length=500, null=True),
        ),
        migrations.AlterField(
            model_name='subcategoria',
            name='aparece_en_portada',
            field=models.BooleanField(default=False, editable=False),
        ),
        migrations.AlterField(
            model_name='subcategoria',
            name='banner_large',
            field=models.ImageField(blank=True, help_text=b'2000x587', null=True, upload_to=b'oferta', verbose_name=b'banner grande'),
        ),
        migrations.AlterField(
            model_name='subcategoria',
            name='banner_small',
            field=models.ImageField(blank=True, help_text=b'968x586', null=True, upload_to=b'oferta', verbose_name=b'banner chico'),
        ),
        migrations.AlterField(
            model_name='subcategoria',
            name='imagen_fondo',
            field=models.ImageField(blank=True, editable=False, null=True, upload_to=b'uploads/oferta'),
        ),
        migrations.AlterField(
            model_name='subcategoria',
            name='imagen_frente',
            field=models.ImageField(blank=True, editable=False, null=True, upload_to=b'uploads/oferta'),
        ),
        migrations.AlterField(
            model_name='subcategoria',
            name='salto_antes',
            field=models.BooleanField(default=True, editable=False),
        ),
    ]

Tags: tonamefalsetruefieldmodelmodelsmigrations