note: answering my own question below.
A:
For some reason users with no permission to the object still have access to it through Inlines. Here's how to delete them dynamically:
class FooAdmin(admin.ModelAdmin):
inlines = ['SomeInline']
...
def change_view(self, request, object_id, extra_context=None):
def delete_inlines(inlines):
for index, inline in reversed(list(enumerate(self.inlines))):
if inline.__name__ in inlines:
del self.inlines[index]
del self.inline_instances[index]
delete_inlines(['SomeInline' ])
return super(FooAdmin, self).change_view(request, object_id, extra_context=None)
orwellian
2009-09-25 13:47:12