In the development version, this functionality is in the “interface” and is documented, but the
site for which you need to extend the functionality of the administrator interface is based on Django 1.0, in which this feature is not yet ...
The essence of expanding the interface (adding an action) is to implement the __call __ (self, request, url) method in the model administration class.
I did this as follows:
class EventAdmin (admin.ModelAdmin):
save_as = true
def __call __ (self, request, url):
print url
If url is not None and url.startswith ('import /'):
return self.import_view (request, unquote (url [7:]))
else:
return super (EventAdmin, self) .__ call __ (request, url)
Those. I first check the URL for the presence of the prefix of my action and call the corresponding view, or transfer control to the parent implementation.
I use import_view to import (with manual processing) an object with a given identifier (i.e., this is add, but with its own specifics), so I ripped off its implementation with change_view :-) Everything turned out to be very simple and logical. Rights to commit an action are verified from the action itself. I left them the same as the original add action.
I hope someone will come in handy :-)