The Template Location of django-tables2


The django-tables2 is a excellent package to creat dynamic HTML tables in Django apps. When I used it the first time, I spent hours to solve a TemplateDoesNotExist error.

I usually store the html templates of an app in [app name]/templates/[app name]/. The Django official documentation suggests this practice to avoid potential template conflicts among different apps. When I used the django-tables2, I put templates for rendering tables under the same path. Then, TemplateDoesNotExist. I searched Github and Stack Overflow, and no one shared the same problem.

I went back to the documentation and read it word by word. I finally found out that the path in the example is tutorial/templates/people.html. That means I should put my django-tables2 template under

[app name]/templates/

NOT

[app name]/templates/[app name]/

A lesson learnt.