[Answered ]-How do I fix my Django app's urls.py so I stop getting a TemplateDoesNotExist exception?

2👍

Assuming that the file /home/sez/blog/templates/blog/post_list.html exists, you only have to tell Django where to look for it. Apparently, it looks for your templates in /home/sez/blog/templates/blogengine/. You can change that by adjusting TEMPLATE_DIRS in your settings.py:

TEMPLATE_DIRS = (
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
    '/home/sez/blog/templates/blog',
)

However, it is common practice to name the template subdirectories as their corresponding apps, so you might want to consider moving your templates to blogengine, where Django assumes they are at the moment.

0👍

You can do two things, either explicitly tell it which template by passing in the template_name parameter, or move post_list.html into /blog/blog/templates/ directory, which is where django will look for it (even if you don’t specify the location in TEMPLATE_DIRS)

From the documentation on generic views:

Template name:

If template_name isn’t specified, this view will use the template
<app_label>/<model_name>_list.html by default.

Leave a comment