Monday, May 13, 2019

Django :: Disable Delete Action


Django :: Disable Delete Action :-

site-packages/django/contrib/admin/options.py :-

class BaseModelAdmin(six.with_metaclass(RenameBaseModelAdminMethods)):
   
     def has_delete_permission(self, request, obj=None):

           return False  # Add this line for diable Delete Action

sites.py :-

class AdminSite(object):

   def __init__(self, name='admin', app_name='admin'):
       #self._actions = {'delete_selected': actions.delete_selected} # Comment this line
        self._actions = {} # add this line

No comments: