From ce621d8e486f1c01e6eb133a55ea69e4acb30548 Mon Sep 17 00:00:00 2001 From: Marcio Mazza Date: Wed, 11 Jul 2018 15:16:09 -0300 Subject: [PATCH] =?UTF-8?q?Corrige=20set=20generic=20fk=20na=20migra=C3=A7?= =?UTF-8?q?=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/legacy/migracao_dados.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sapl/legacy/migracao_dados.py b/sapl/legacy/migracao_dados.py index 4c953d5f5..45b3c9338 100644 --- a/sapl/legacy/migracao_dados.py +++ b/sapl/legacy/migracao_dados.py @@ -141,10 +141,6 @@ models_novos_para_antigos = { for model in field_renames} models_novos_para_antigos[Composicao] = models_novos_para_antigos[Participacao] -content_types = {model: ContentType.objects.get( - app_label=model._meta.app_label, model=model._meta.model_name) - for model in field_renames} - campos_novos_para_antigos = { model._meta.get_field(nome_novo): nome_antigo for model, renames in field_renames.items() @@ -1156,7 +1152,9 @@ def adjust_tipoafastamento(new, old): def set_generic_fk(new, campo_virtual, old): - new.content_type = content_types[campo_virtual.related_model] + model = campo_virtual.related_model + new.content_type = ContentType.objects.get( + app_label=model._meta.app_label, model=model._meta.model_name) new.object_id = get_fk_related(campo_virtual, old)