python - Django TemplateDoesNotExist {% extends base.html %} - where should template be? -
i'm starting simple django app having trouble extending html file.
i have base.html , index.html both within my_site/my_app/templates/my_app.
i.e. my_site/my_app/templates/my_app/base.html , my_site/my_app/templates/my_app/index.html.
within index.html file have {% extends 'base.html' %}.
my settings.py file has
base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) templates = [ { 'backend': 'django.template.backends.django.djangotemplates', 'dirs': [os.path.join(base_dir, 'templates')], 'app_dirs': true, 'options': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] but when visit index view @ http://127.0.0.1:8000/index/:
def index(request): return render(request, 'my_app/index.html') i following error:
templatedoesnotexist @ /index/ base.html request method: request url: http://127.0.0.1:8000/index/ django version: 1.10.3 exception type: templatedoesnotexist exception value: base.html do have base.html file saved in wrong place or else? have not been able solve this.
it should in my_site/my_app/templates or my_site/templates.
Comments
Post a Comment