I asked too soon. Sorry.
There is a method in contrib.admin.options.BaseModelAdmin called ...
def has_delete_permission(self, request, obj=None): """ Returns True if
the given request has permission to change the given Django model
instance, the default implementation doesn't examine the `obj`
parameter. Can be overridden by the user in subclasses. In such case it
should return True if the given request has permission to delete the
`obj` model instance. If `obj` is None, this should return True if the
given request has permission to delete *any* object of the given type.
""" opts = self.opts codename = get_permission_codename('delete', opts)
return request.user.has_perm("%s.%s" % (opts.app_label, codename))
So I made a callable ...
def see_delete_button(self, request, obj=None): from django.contrib.auth
import get_permission_codename opts = self.opts codename =
get_permission_codename('delete', opts) see =
request.user.has_perm("%s.%s" % (opts.app_label, codename)) if obj: if
obj.company == get_user_company(request.user): return see and True else:
return False return see
In myModelAdmin I put ... has_delete_permission = see_delete_button
And it works nicely :) Open source is lovely and Django (and the Admin)
is brilliant.
I'm guessing showing the button disabled would be a CSS task which I
don't have the brain-space for just now.
Cheers
Mike