What is the most efficient way to check if a template exists in Django? I was thinking of catching the TemplateDoesNotExist exception, but maybe there is a more Djangoistic way to do it?
Thanks for your help!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I don’t think you’ll be able to do this without catching this exception, but you could use
django.template.loader.get_template(template_name)in your try statement instead of a optimist call of render_to_response. (If you are not already doing this…)