From ce0d0ff6e9232011c7f191d928dd324e0421e6fa Mon Sep 17 00:00:00 2001 From: Luciano Almeida Date: Mon, 8 May 2017 15:56:22 -0300 Subject: [PATCH] Muda jeito e pegar ultimo valor do model Signed-off-by: Luciano Almeida --- sapl/legacy/migration.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sapl/legacy/migration.py b/sapl/legacy/migration.py index 6ab3cd184..0d2f5be10 100644 --- a/sapl/legacy/migration.py +++ b/sapl/legacy/migration.py @@ -130,9 +130,7 @@ def get_fk_related(field, value, label=None): if not field.null: fields_dict = get_fields_dict(field.related_model) # Cria stub ao final da tabela para evitar erros - pk = 1 - if hasattr(field.related_model.objects.last(), 'pk'): - pk = field.related_model.objects.last().pk + pk = get_last_value(field.related_model) with reversion.create_revision(): reversion.set_comment('Stub criado pela migração') value = mommy.make(