[Fixed]-TemplateDoesNotExist & {% extends "base.html" %} error

1👍

This ended up being a bizarre browser/django/cache issue involved with a corrupted project. The power went out where I’m working from the day I posted this and something must have happened that didn’t lead me toward the answer but didn’t prevent me from using the same project instance altogether.

If you run into something like this, I guess the answer is to have a backup.

0👍

I’d advise moving your templates folder to one of your apps, probably redditpanel in this case. I suspect that since they are in the root project folder Django is having a hard time finding them.

What I usually have is this structure:

- project (root folder)
|- app_x
 |- views.py
 |- templates
   |- template_x.html
|- app_y
 |- views.py
 |- templates
   |- template_y.html
|- project
 |- settings.py

This way, in each app’s view you can reference the template directly and Django will search in this app’s template folder, e.g.:

# in "app_x" views.py
class MyView(TemplateView):
    template_name = 'my_view.html'

# then, in "app_x"'s template folder you can create "my_view.html" file to be used in this view

Could you try this out and tell us the results?

👤Ícaro

Leave a comment