[Fixed]-Different type of obj for response_add() and response_delete()

1👍

The only thing I’ve found so far that calls response_delete is the DeleteView

Which has a comment a few lines above it stating that the object has been deleted.

if request.POST and not protected:  # The user has confirmed the deletion.
    if perms_needed:
        raise PermissionDenied
    obj_display = force_text(obj)
    attr = str(to_field) if to_field else opts.pk.attname
    obj_id = obj.serializable_value(attr)
    self.log_deletion(request, obj, obj_display)
    self.delete_model(request, obj)

    return self.response_delete(request, obj_display, obj_id)

Therefore there is nothing left to query about it, it has no data left attached to it.

why in my response_add the type of variable obj is object but in reponse_delete is a string which I need is an object also.

  • response_add is returning the newly created object
  • response_delete is returning a string representation of the defunct object

So what can you do?

Most likely you need a pre_delete signal to do so pre-processing but its hard to say.

👤Sayse

Leave a comment