My Views.py files looks like below
def homepage(request):
template = 'homepage.html'
list_display_template = 'list.html'
list = model.objects.all()
return render_to_response(template,
{'list_display_template': list_display_template,
'list' : list,},
context_instance=RequestContext(request))
And my homepage.html looks like below:-
{% extends "base.html" %}
{% block main_content %}
{% include list_display_template %}
{% endblock %}
And my list_display_template (list.html) has following information
< div class= "span10">
{% for item in list %}
<p> {{ item }}</p>
{% endfor %}
</div>
The above works fine in development, but in production the include tag is not working and when i inspect the element, it is not showing any items from list.html. could someone help with this.
Edit :- My folder structure is as below
project_name/
project_name/
settings.py
static/
css/
images/
templates/
homepage.html
list.html
base.html
Thanks
conf. urls import include is already there. In newer versions of Django, the include admin is not required anymore so django does not already have the import include part. So all you need to do to fix this in newer versions is just add the import of include there.
Django TemplateDoesNotExist error means simply that the framework can't find the template file. To use the template-loading API, you'll need to tell the framework where you store your templates. The place to do this is in your settings file ( settings.py ) by TEMPLATE_DIRS setting.
I had the same problem,but i will answer this question in a way that other users with a similar problem can understand.
you probably have a template block of some kind in the included html file,
this block either is expecting an include of some kind or is causing an error of which is calling exception that django passes and therefore you are not able to see the error,
if you use {% load someLoad %}
in the parent template then use it in the included html too,
i guess this changes from version to version.
in my (very specific) case i had this missing in the included html file:
{% load i18n %}
{% load cms_tags sekizai_tags %}
Another situation where an include statement will fail without raising an error is if you are working in a template which extends another, and your include is outside of a named block:
{% extends "my_base.html" %}
{% block content %}
{{ block.super }}
{% include "partials/file1.html" %}
{% endblock %}
{% include "partials/file2.html" %}
In this case file2.html will not be included because it is not in a block, and you will get no warning messages, and will try all sorts of things before you realise what you've done :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With