def template_exists(form, field):
try:<EOL><INDENT>current_app.jinja_env.get_template(field.data)<EOL><DEDENT>except TemplateNotFound:<EOL><INDENT>raise ValidationError(_("<STR_LIT>"))<EOL><DEDENT>
Form validation: check that selected template exists.