Check for a broken ContentType -> model and log and skip

Apparently this has happened to a customer, per Nate Becker.
This commit is contained in:
Jeff Bradberry 2024-05-06 10:31:17 -04:00
parent 1f154742df
commit 0e87e97820

View File

@ -13,6 +13,9 @@ orphaned_roles = []
for ct in ContentType.objects.order_by('id'):
cls = ct.model_class()
if cls is None:
sys.stderr.write(f"{ct!r} does not have a corresponding model class in the codebase. Skipping.\n")
continue
if not any(isinstance(f, ImplicitRoleField) for f in cls._meta.fields):
continue
for obj in cls.objects.all():