[Django]-How do I conditionally veto a delete attempt in Django Admin 1.5?

3👍

You should be able to accomplish this by overriding has_delete_permission(request, obj) in your Chain admin. You can check obj to see if any Targets are referencing it. See the docs.

This won’t prevent deletion via the Delete selected action in the change list view, though. You can fix that by overriding the built-in delete_selected action with your own that refuses to do the delete if any of the items shouldn’t be deleted. See the Admin action docs.

Leave a comment