Template Loader finds the template but template is not loaded
TemplateDoesNotExist at /cardpayment/
cardpayment.html
Request Method: GET
Request URL: http://localhost:7000/cardpayment/
Django Version: 1.8
Exception Type: TemplateDoesNotExist
Exception Value:
cardpayment.html
Exception Location: /home/sdr/sl/lib/python3.4/site-packages/django/template/loader.py in render_to_string, line 138
Python Executable: /home/sdr/sl/bin/python
Python Version: 3.4.3
Python Path:
['/home/sdr/sl/agryp',
'/home/sdr/pycharm-4.0.6/helpers/pydev',
'/home/sdr/sl/src/tastypie',
'/home/sdr/sl/agryp',
'/usr/local/lib/python34.zip',
'/usr/local/lib/python3.4',
'/usr/local/lib/python3.4/plat-linux',
'/usr/local/lib/python3.4/lib-dynload',
'/home/sdr/sl/lib/python3.4/site-packages']
Server time: Tue, 5 May 2015 10:17:40 +0000
Template-loader postmortem
Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
/home/sdr/sl/agryp/templates/cardpayment.html (File does not exist)
Using loader django.template.loaders.app_directories.Loader:
/home/sdr/sl/agryp/agryp/templates/cardpayment.html (File exists) <=========== FILE EXISTS BUT NOT LOADED
/home/sdr/sl/src/tastypie/tastypie/templates/cardpayment.html (File does not exist)
/home/sdr/sl/lib/python3.4/site-packages/grappelli/templates/cardpayment.html (File does not exist)
/home/sdr/sl/lib/python3.4/site-packages/django/contrib/admin/templates/cardpayment.html (File does not exist)
/home/sdr/sl/lib/python3.4/site-packages/django/contrib/auth/templates/cardpayment.html (File does not exist)
/home/sdr/sl/lib/python3.4/site-packages/oauth2_provider/templates/cardpayment.html (File does not exist)
/home/sdr/sl/lib/python3.4/site-packages/selectable/templates/cardpayment.html (File does not exist)
As it can be clearly seen, the loader is able to find the template.
The TEMPLATE_DIRS value in settings.py is as follows:
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',
'allauth.account.context_processors.account',
'allauth.socialaccount.context_processors.socialaccount',
],
},
},
]
I have tried to move the template to project/templates directory as well but the error persists.
Code checks out with 0 errors/warnings.
contents of cardpayment.html
{% extends "base.html" %}
{% block title %}Card Payments over Phone{% endblock %}
{% block extrahead %}
{% load selectable_tags %}
{% include_ui_theme %}
{% endblock %}
{% block content %}
<h1>Receive Card Payment</h1>
<form name="paymentType" id="paymentType" class="form-horizontal">
<fieldset>
<label>Check type of Customer
<input type="radio" value="existing">Existing Customer<br />
<input type="radio" value="new">Nee Customer<br />
</label>
</fieldset>
</form>
<div class="row">
<form class="form-horizontal">
<table class="table-responsive table-bordered">
{{ form.as_table }}
</table>
</form>
</div>
{% endblock %}
See Question&Answers more detail:
os