Skip to content
Snippets Groups Projects
Verified Commit 296fb6c8 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Fix DoesNotExist exception in has_any_object

parent fc9e81c1
No related branches found
No related tags found
1 merge request!347Fix DoesNotExist exception in has_any_object
Pipeline #3334 failed
......@@ -64,7 +64,10 @@ def has_any_object(perm: str, klass):
@predicate(name)
def fn(user: User) -> bool:
ct_perm = ContentType.objects.get(app_label=perm.split('.', 1)[0], permission__codename=perm.split('.', 1)[1])
try:
ct_perm = ContentType.objects.get(app_label=perm.split('.', 1)[0], permission__codename=perm.split('.', 1)[1])
except ContentType.DoesNotExist:
ct_perm = None
if ct_perm and ct_perm.model_class() == klass:
return get_objects_for_user(user, perm, klass).exists()
else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment