当尝试将迁移应用于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 ”,当我在其他应用上运行迁移时,这会显示出来。
这是我从django 1.4更新的遗留项目。我在'oferta'和'casos'之间有一个循环的迁移依赖问题,我设法通过将'oferta'的引用移到'casos'中的第二次迁移来解决。
要完整的追溯和迁移:
Operations to perform:
Apply all migrations: partners, redirects, sessions, admin, casos, sonda_core, oferta, flatpages, sites, noticias, contenttypes, auth, industrias, tags
Running migrations:
Rendering model states...Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/rodrigo/Envs/s16/lib/python2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
utility.execute()
File "/Users/rodrigo/Envs/s16/lib/python2.7/site-packages/django/core/management/__init__.py", line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/rodrigo/Envs/s16/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/rodrigo/Envs/s16/lib/python2.7/site-packages/django/core/management/base.py", line 399, in execute
output = self.handle(*args, **options)
File "/Users/rodrigo/Envs/s16/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 200, in handle
executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
File "/Users/rodrigo/Envs/s16/lib/python2.7/site-packages/django/db/migrations/executor.py", line 92, in migrate
self._migrate_all_forwards(plan, full_plan, fake=fake, fake_initial=fake_initial)
File "/Users/rodrigo/Envs/s16/lib/python2.7/site-packages/django/db/migrations/executor.py", line 118, in _migrate_all_forwards
state.apps # Render all -- performance critical
File "/Users/rodrigo/Envs/s16/lib/python2.7/site-packages/django/utils/functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Users/rodrigo/Envs/s16/lib/python2.7/site-packages/django/db/migrations/state.py", line 162, in apps
return StateApps(self.real_apps, self.models)
File "/Users/rodrigo/Envs/s16/lib/python2.7/site-packages/django/db/migrations/state.py", line 235, in __init__
raise ValueError(self._pending_models_error(pending_models))
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 /迁移/ 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 /迁移/ 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),
),
]