Should have done it this way to begin with

maintains compatibility with django<1.4. Copied from django-grappelli
commit 4b992de26a25bfbd036a3f1732cf6c3ff54426cb