diff --git a/django/contrib/contenttypes/migrations/0002_remove_content_type_name.py b/django/contrib/contenttypes/migrations/0002_remove_content_type_name.py index b2e18846b9a..044fb615cf0 100644 --- a/django/contrib/contenttypes/migrations/0002_remove_content_type_name.py +++ b/django/contrib/contenttypes/migrations/0002_remove_content_type_name.py @@ -9,7 +9,7 @@ def add_legacy_name(apps, schema_editor): for ct in ContentType.objects.all(): try: ct.name = apps.get_model(ct.app_label, ct.model)._meta.object_name - except: + except LookupError: ct.name = ct.model ct.save()