From 87c50f125d4be9cffe46eb0f619f7033a52ba3c4 Mon Sep 17 00:00:00 2001 From: KK Date: Wed, 20 Dec 2023 18:22:06 +0100 Subject: [PATCH] fix: deletion of entity objects In GenericEntitiesDeleteView, override get_queryset() method instead of referencing a specific (parent) model to get at the object-to-be-deleted. Closes #485 --- apis_core/apis_entities/edit_generic.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apis_core/apis_entities/edit_generic.py b/apis_core/apis_entities/edit_generic.py index cffc30787..bb83cb889 100644 --- a/apis_core/apis_entities/edit_generic.py +++ b/apis_core/apis_entities/edit_generic.py @@ -165,13 +165,13 @@ def post(self, request, *args, **kwargs): @method_decorator(login_required, name="dispatch") class GenericEntitiesDeleteView(EntityInstanceMixin, DeleteView): - # model = ContentType.objects.get( - # app_label='apis_entities', model='tempentityclass').model_class() - model = importlib.import_module("apis_core.apis_entities.models").TempEntityClass template_name = getattr( settings, "APIS_DELETE_VIEW_TEMPLATE", "confirm_delete.html" ) + def get_queryset(self): + return self.entity_model.objects.all() + def dispatch(self, request, *args, **kwargs): self.success_url = reverse( "apis_core:apis_entities:generic_entities_list",