Cutsumizing Django auto generated admin area

Content on this page is probably outdated and represents my personal knowledge, feelings and understading of things at that time.

So, I’m planing to do a mini series of (mostly) self notes on how to customize/add/remove various parts of Django’s auto generated admin area.

So for a quick start something easy/minimal, that I tend to forget.

Adding custom url handlers


This is especially useful if one tends to add some AJAX to the admin area.
For this, you’ll need to override the call method of your ModelAdmin. Example code:

def call(self, request, url):
"""
Delegate to the appropriate method, based on the URL.
"""
if url is None:
# default url handler
return super(PageAdmin, self).call(request, url)
elif url.endswith(‘move-page’):
return self.move_page(request, unquote(url[:-10]))

So, if the url ends with move-page ( eg. /admin/<app>/<model>/move-page/ ) the move_page method will be called. You can ( must ) return one of the Django HTTP objects.

I’ll continue with some ( at least for me ) tricky stuff.