I am getting a template does exist error for two HTML pages I have placed the error message below
TTemplateDoesNotExist at /deck/15/
template_folder/create_cards.html
Request Method: GET
Request URL: http://127.0.0.1:8000/deck/15/
Django Version: 4.1.13
Exception Type: TemplateDoesNotExist
Exception Value:
template_folder/create_cards.html
Exception Location: C:UsersbotanAppDataLocalProgramsPythonPython312Libsite-packagesdjangotemplateloader.py, line 19, in get_template
Raised during: cardDesigner.views.create_cards
Python Executable: C:UsersbotanAppDataLocalProgramsPythonPython312python.exe
Python Version: 3.12.2
Python Path:
[‘C:UsersbotanDesktopprojectlanguages’,
‘C:UsersbotanAppDataLocalProgramsPythonPython312python312.zip’,
‘C:UsersbotanAppDataLocalProgramsPythonPython312DLLs’,
‘C:UsersbotanAppDataLocalProgramsPythonPython312Lib’,
‘C:UsersbotanAppDataLocalProgramsPythonPython312’,
‘C:UsersbotanAppDataLocalProgramsPythonPython312Libsite-packages’]
html
{% extends "base.html" %}
{% block content %}
<div class="container">
<div class="jumbotron">
<h1 class="display-3">{{deck.title}}</h1>
<p class="lead">By {{deck.creator}} in {{deck.subject}}</p>
<p>{{deck.description}}</p>
<hr class="my-4">
<form method="POST">
{% csrf_token %}
{{ formset.management_form }}
{% for form in formset %}
{{form.as_table}}
<br>
<hr>
{% endfor %}
<br>
<button type="submit" class="save btn btn-primary">Save deck</button>
</form>
</div>
</div>
{% endblock %}
views.py
def create_cards(request, deck_id):
deck = Deck.objects.get(pk=deck_id)
if request.method == 'POST':
formset = CardFormSet(request.POST, instance = deck)
if formset.is_valid():
formset.save()
return redirect('create_cards', deck_id)
formset = CardFormSet(instance=deck)
return render(request, "template_folder/create_cards.html", {'formset':formset, 'deck': deck})
in the settings.py file I have also correctly coded the all?
settings.py
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',
],
},
Aan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.