How to Solve NameError: name 'TemplateNotFound' is not defined -- jinja2
Solution: Import the 'TemplateNotFound' module
# Add the following line to the top of your code
from jinja2 import TemplateNotFound
For more information:
jinja2 TemplateNotFound