correct get_objects to return 404 with wrong value

This commit is contained in:
Andreas Zweili 2020-02-29 19:01:16 +01:00
parent 1123aeb259
commit 19ff961cfa
1 changed files with 6 additions and 8 deletions

View File

@ -59,11 +59,9 @@ def get_objects(model_name, user):
'softwares',
'users',
]
try:
for name in app_names:
app = apps.get_app_config(name)
if model_name in app.models:
model = app.models[model_name]
return model.objects.filter(customer__in=customers)
except KeyError:
raise Http404("Model ", model_name, " not found.")
for name in app_names:
app = apps.get_app_config(name)
if model_name in app.models:
model = app.models[model_name]
return model.objects.filter(customer__in=customers)
raise Http404("Model ", model_name, " not found.")