make unloading safer

This commit is contained in:
Matthias 2022-05-04 17:40:44 +02:00
parent b16305afef
commit cf986e557c
No known key found for this signature in database
GPG Key ID: AB6D0E6C4CB65093

View File

@ -523,7 +523,10 @@ class PluginsRegistry:
# check all models # check all models
for model in app_config.get_models(): for model in app_config.get_models():
# remove model from admin site # remove model from admin site
admin.site.unregister(model) try:
admin.site.unregister(model)
except:
pass
models += [model._meta.model_name] models += [model._meta.model_name]
except LookupError: # pragma: no cover except LookupError: # pragma: no cover
# if an error occurs the app was never loaded right -> so nothing to do anymore # if an error occurs the app was never loaded right -> so nothing to do anymore