From ff8d715a0a62eb4d70e6c2bf38fa1113ed2899e5 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Mon, 21 Jul 2014 10:09:31 +0100 Subject: [PATCH] [1.7.x] Fixed #23039: Don't try to serialize unmanaged models in tests --- django/db/backends/creation.py | 2 +- tests/migration_test_data_persistence/models.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/django/db/backends/creation.py b/django/db/backends/creation.py index 752eac75cd..ad9fe99ccb 100644 --- a/django/db/backends/creation.py +++ b/django/db/backends/creation.py @@ -409,7 +409,7 @@ class BaseDatabaseCreation(object): # Make a function to iteratively return every object def get_objects(): for model in sort_dependencies(app_list): - if not model._meta.proxy and router.allow_migrate(self.connection.alias, model): + if not model._meta.proxy and model._meta.managed and router.allow_migrate(self.connection.alias, model): queryset = model._default_manager.using(self.connection.alias).order_by(model._meta.pk.name) for obj in queryset.iterator(): yield obj diff --git a/tests/migration_test_data_persistence/models.py b/tests/migration_test_data_persistence/models.py index 1b0b795d2c..c1572d5ddf 100644 --- a/tests/migration_test_data_persistence/models.py +++ b/tests/migration_test_data_persistence/models.py @@ -3,3 +3,10 @@ from django.db import models class Book(models.Model): title = models.CharField(max_length=100) + + +class Unmanaged(models.Model): + title = models.CharField(max_length=100) + + class Meta: + managed = False