Ticket #17515: filterspec_custom_templates.diff

File filterspec_custom_templates.diff, 1.1 KB (added by Stefano Apostolico, 13 years ago)
  • django/contrib/admin/templatetags/admin_list.py

     
    1313from django.utils.translation import ugettext as _
    1414from django.utils.encoding import smart_unicode, force_unicode
    1515from django.template import Library
     16from django.template.loader import get_template
     17from django.template.context import Context
    1618
    17 
    1819register = Library()
    1920
    2021DOT = '.'
     
    360361        'search_var': SEARCH_VAR
    361362    }
    362363
    363 @register.inclusion_tag('admin/filter.html')
     364@register.simple_tag()
    364365def admin_list_filter(cl, spec):
    365     return {'title': spec.title, 'choices' : list(spec.choices(cl))}
     366    if hasattr(spec, 'template') and spec.template:
     367        t = get_template(spec.template)
     368    else:
     369        t = get_template('admin/filter.html')
     370    ctx = Context({'title': spec.title, 'choices' : list(spec.choices(cl)), 'spec': spec})
     371    return t.render(ctx)
    366372
    367373@register.inclusion_tag('admin/actions.html', takes_context=True)
    368374def admin_actions(context):
Back to Top