Ticket #17515: filterspec_custom_templates.diff
File filterspec_custom_templates.diff, 1.1 KB (added by , 13 years ago) |
---|
-
django/contrib/admin/templatetags/admin_list.py
13 13 from django.utils.translation import ugettext as _ 14 14 from django.utils.encoding import smart_unicode, force_unicode 15 15 from django.template import Library 16 from django.template.loader import get_template 17 from django.template.context import Context 16 18 17 18 19 register = Library() 19 20 20 21 DOT = '.' … … 360 361 'search_var': SEARCH_VAR 361 362 } 362 363 363 @register. inclusion_tag('admin/filter.html')364 @register.simple_tag() 364 365 def 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) 366 372 367 373 @register.inclusion_tag('admin/actions.html', takes_context=True) 368 374 def admin_actions(context):