Skip to content
This repository has been archived by the owner on Oct 18, 2022. It is now read-only.

add: handle protected error in base delete view #130

Open
wants to merge 1 commit into
base: development
Choose a base branch
from

Conversation

acolazo
Copy link

@acolazo acolazo commented Feb 9, 2022

Currently when deleting an object through the BaseDeleteView that is referenced by Foreign Keys with PROTECT as the on_delete option will cause an HTTP 500 Error.

This PR implementes changes to BaseDeleteView to handle Protected Errors. When an error occurs it will send a HTTP Redirect to the object's absolute URL with an error message stating that the object cannot be deleted.

@@ -308,6 +311,24 @@ def get_success_url(self):
model_name = self.model.__name__.lower()
return reverse('{}_list'.format(model_name))

def post(self, request, *args, **kwargs):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

def delete, super().delete para que funcione para ambos metodos http

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants