The Django documentation states the following clearly:
Not every template in contrib\admin\templates\admin may be overridden per app or per model.
It then lists the ones that can, and base.html
, base_site.html
and index.html
– the ones I'm interested in – are not among those listed. They can be overridden per-project, but not per-app.
My question is: is there a way around this that doesn't involve editing the code inside django.contrib.admin? I'm willing to consider some monkeypatching solutions :-). I really want my app to have custom versions of those three files inside its templates
directory, and have each project that uses the app to use those.
The reason I'm interested is that I'm creating a large, reusable app with a heavily customized admin interface, and per-project overrides of the "core" templates aren't the best solution, since I'd have to copy the custom templates to the template directory of each project that the app gets used in. Releasing new versions of the app with new modifications to those core templates would mean re-copying everything to the affected projects. Ugh.
I understand the reasoning behind the decision to only make a select few templates overridable per-app; after all, if overriding them all was possible, which app's overridden admin would take precedence?
But in my case, the app will be the "centerpiece" of several client projects, with other apps in those projects merely being in a supporting role.
CSS-based customization of the existing templates only gets you so far, and I'm hesitant to rely on JavaScript DOM manipulation solutions unless absolutely necessary.
One solution that comes to mind is to place the custom base.html
etc. templates inside appname/templates/admin/ and then symlink them to the project's templates folder. That way any updates to the app will automatically take effect on the project level.
Symlinking is probably my method of choice if nothing better is suggested, but I'd like to hear if anyone has a nicer solution.