Code

Ticket #16502: handle_empty_list_of_templates_r16549.diff

File handle_empty_list_of_templates_r16549.diff, 614 bytes (added by Silver_Ghost, 3 years ago)

Adds check for non-emptyness for list of template_names in django.template.loader.select_template.

Line 
1Index: django/template/loader.py
2===================================================================
3--- django/template/loader.py   (revision 16549)
4+++ django/template/loader.py   (working copy)
5@@ -180,6 +180,9 @@
6 def select_template(template_name_list):
7     "Given a list of template names, returns the first that can be loaded."
8     not_found = []
9+    if not template_name_list:
10+        raise ValueError("Couldn't choose template for load since there are"
11+                         " no candidates")
12     for template_name in template_name_list:
13         try:
14             return get_template(template_name)