Like :class:`TemplateNotFound` but raised if multiple templates are selected. This is a subclass of :class:`TemplateNotFound` exception, so just catching the base exception will catch both. .. versionadded:: 2.2
| 62 | |
| 63 | |
| 64 | class TemplatesNotFound(TemplateNotFound): |
| 65 | """Like :class:`TemplateNotFound` but raised if multiple templates |
| 66 | are selected. This is a subclass of :class:`TemplateNotFound` |
| 67 | exception, so just catching the base exception will catch both. |
| 68 | |
| 69 | .. versionadded:: 2.2 |
| 70 | """ |
| 71 | |
| 72 | def __init__(self, names=(), message=None): |
| 73 | if message is None: |
| 74 | message = u'none of the templates given were found: ' + \ |
| 75 | u', '.join(imap(text_type, names)) |
| 76 | TemplateNotFound.__init__(self, names and names[-1] or None, message) |
| 77 | self.templates = list(names) |
| 78 | |
| 79 | |
| 80 | @implements_to_string |