I am "trying" to develop a Django project with Bootstrap. Because each page requires the exact same Bootstrap code, it looks more logical to me to have one base template at project level.
Learning from this guide and this guide, here's the content of my project files:
settings.py
'DIRS': [(os.path.join(BASE_DIR, 'templates')),],
urls.py
urlpatterns = [
path('admin/', admin.site.urls),
path('', views.homepage, name='homepage'),
]
views.py
def homepage(request):
return render(request, 'homepage/index.html')
index.html
{% extends 'base.html' %}
{% block title %}Hello from index.html{% endblock %}
{% block content %}
This is from the index.html
{% endblock %}
Now when I browse the homepage of site (localhost:8000) I get TemplateDoesNotExist error. When I look at the error details I see this:
Template-loader postmortem
Django tried loading these templates, in this order:
Using engine django:
django.template.loaders.filesystem.Loader: D:\Django Projects\omidshojaee.com\omidshojaee_com\templates\base.html (Source does not exist)
So Django is looking into the correct folder, and base.html is there (I can see it with my own eyes), so why Django cannot load it?
Edit: I should have explained the folder structure. It looks like this:
index.html inside omidshojaee_com(this is the project name)/homepage(this is the app name)/templates/homepage/
base.html inside omidshojaee_com/templates/
What I want is to have one base.html shared between all apps.