I want to override the default django admin filter template to use my own template based on this:
https://github.com/feincms/feincms/blob/master/feincms/templates/admin/filter.html
I wrote my own class SimpleListFilter, inheriting fromdjango.contrib.admin.SimpleListFilter
class PublisherStateFilter(admin.SimpleListFilter):
title = _('Status')
parameter_name = 'status'
template = 'admin/blogitty/filter.html'
[...]
This works great.

However, I would like to use the same template for all admin filters. Is there a way to bypass all filter patterns for a given application without having to define a custom one ListFilterfor each relationship ForeignKeyand ManyToMany.
In my project blogitty. I tried both options for the DIR pattern:
blogitty/templates/admin/filter.html
and
blogitty/templates/admin/blogitty/filter.html
Bad luck: - (
Looking through the source code:
https://github.com/django/django/blob/master/django/contrib/admin/options.py#L1030
return TemplateResponse(request, form_template or [
"admin/%s/%s/change_form.html" % (app_label, opts.model_name),
"admin/%s/change_form.html" % app_label,
"admin/change_form.html"
], context)
https://github.com/django/django/blob/master/django/contrib/admin/options.py#L1569
return TemplateResponse(request, self.change_list_template or [
'admin/%s/%s/change_list.html' % (app_label, opts.model_name),
'admin/%s/change_list.html' % app_label,
'admin/change_list.html'
], context)
. Django ModelAdmin changeform changelist . ListFilter .
https://github.com/django/django/blob/master/django/contrib/admin/filters.py#L60
class ListFilter(object):
title = None
template = 'admin/filter.html'
- TEMPLATE_DIRS:
BASE_DIR = dirname(dirname(__file__))
TEMPLATE_DIRS = (
join(BASE_DIR, 'templates'),
)
cookiecutter-django Daniel Greenfeld