Admin delete page should present 404 page on non-existing object
@@ -190,7 +190,10 @@ def refine_with_params(self, app_name: str = None, model_name: str = None, pk: s
refined_admin = self.refine(app_name=app_name, model_name=model_name)
model = django_apps.all_models[app_name][model_name] if app_name and model_name else None
+ try:
instance = model.objects.get(pk=pk) if pk is not None else None
+ except model.DoesNotExist:
+ raise Http404()
if model is not None and instance is None:
refined_admin = refined_admin.refine(model=model, parts__table__auto__model=model)
