you should be able to use "isinstance(template, compat.string_types)" here