Ticket #4250: allow-lists-for-templates.2.patch

File allow-lists-for-templates.2.patch, 1.8 KB (added by adamfast@…, 8 years ago)

Patch to django/views/generic/list_detail.py and django/template/loader.py

  • C:/Python24/Lib/site-packages/django/views/generic/list_detail.py

     
    117117        template_name_list = [getattr(obj, template_name_field), template_name]
    118118        t = template_loader.select_template(template_name_list)
    119119    else:
    120         t = template_loader.get_template(template_name)
     120        t = template_loader.select_template(template_name)
    121121    c = RequestContext(request, {
    122122        template_object_name: obj,
    123123    }, context_processors)
  • C:/Python24/Lib/site-packages/django/template/loader.py

     
    109109    "Given a list of template names, returns the first that can be loaded."
    110110    for template_name in template_name_list:
    111111        try:
    112             return get_template(template_name)
     112            if len(template_name) == 1: #this can't be a complete template path, it must be a plain string
     113                return get_template(template_name_list)
     114            else:
     115                return get_template(template_name)
    113116        except TemplateDoesNotExist:
    114117            continue
    115118    # If we get here, none of the templates could be loaded
    116     raise TemplateDoesNotExist, ', '.join(template_name_list)
     119    if len(template_name_list[0]) == 1:
     120        raise TemplateDoesNotExist, template_name_list
     121    else:
     122        raise TemplateDoesNotExist, ', '.join(template_name_list)
    117123
    118124add_to_builtins('django.template.loader_tags')
Back to Top