Alloy
Alloy

Reputation: 418

TemplateDoesNotExist & {% extends "base.html" %} error

I'm having an issue that I personally have been unable to resolve and I think the easiest way to ask for help is to link to the github folder where the error references I've been pushing to and include this screenshot.

templatedoestnotexist error screenshot

I've looked at the other questions with very similar context and I've actually tried almost every single thing I've found. Some of it was related to project structure, some of it related to syntax or logic but I cannot find any such problem in my code and as a result, I've also probably added things/changed things that I didn't need to.

It's a sign I need help with the problem.

Upvotes: 0

Views: 672

Answers (2)

Alloy
Alloy

Reputation: 418

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.

Upvotes: 1

Ícaro
Ícaro

Reputation: 1610

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?

Upvotes: 0

Related Questions