diff --git a/django/core/serializers/python.py b/django/core/serializers/python.py index 249dc5a054d32..aa21598695f79 100644 --- a/django/core/serializers/python.py +++ b/django/core/serializers/python.py @@ -90,7 +90,13 @@ def Deserializer(object_list, **options): for d in object_list: # Look up the model and starting build a dict of data for it. - Model = _get_model(d["model"]) + try: + Model = _get_model(d["model"]) + except base.DeserializationError as e: + if ignore: + continue + else: + raise e data = {} if 'pk' in d: data[Model._meta.pk.attname] = Model._meta.pk.to_python(d.get("pk", None)) diff --git a/docs/ref/django-admin.txt b/docs/ref/django-admin.txt index 93087698a020f..b7fbff545b106 100644 --- a/docs/ref/django-admin.txt +++ b/docs/ref/django-admin.txt @@ -380,9 +380,11 @@ onto which the data will be loaded. .. django-admin-option:: --ignorenonexistent -The :djadminopt:`--ignorenonexistent` option can be used to ignore fields that -may have been removed from models since the fixture was originally generated. +The :djadminopt:`--ignorenonexistent` option can be used to ignore fields and models that +may have been removed since the fixture was originally generated. +.. versionchanged:: 1.7 + ``-ignorenonexistent`` behaviour was modified to ignore non existing models. .. versionchanged:: 1.7 diff --git a/docs/releases/1.7.txt b/docs/releases/1.7.txt index fc1f0f81cd694..49d0dfa9113d2 100644 --- a/docs/releases/1.7.txt +++ b/docs/releases/1.7.txt @@ -597,6 +597,9 @@ Management Commands * :djadmin:`collectstatic` command with symlink option is now supported on Windows NT 6 (Windows Vista and newer). +* The `ignorenonexistent`option of loaddata management command now ignore data + for models that no longer exist. + Models ^^^^^^ diff --git a/tests/fixtures_regress/fixtures/sequence_extra.json b/tests/fixtures_regress/fixtures/sequence_extra.json index 03c0f36696bc2..6465fe5a6efda 100644 --- a/tests/fixtures_regress/fixtures/sequence_extra.json +++ b/tests/fixtures_regress/fixtures/sequence_extra.json @@ -9,5 +9,16 @@ "count": 3, "weight": 1.2 } + }, + { + "pk": "1", + "model": "fixtures_regress.animal_extra", + "fields": { + "name": "Lion", + "extra_name": "Super Lion", + "latin_name": "Panthera leo", + "count": 3, + "weight": 1.2 + } } ]