index.html:
...
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<title>{% block tag_title %}THIS IS TEMPORARY{% endblock %}</title>
</head>
...
index_title.html:
{% extends "index.html" %}
{% block tag_title %}THIS IS NOT TEMPORARY{% endblock %}
I've tried various forms of this, but to no avail. I can zip up the
project and forward it along to anyone who would be willing to help.
It doesn't seem like it would be a hard problem for someone who knows
Django well.
The problem is that there are no errors. The output is just
unexpected. The text and code I put into the file which is index's
extension doesn't show up. I put in a default value between the
index.html block. Then I've tried to extend the block with an
alternate text and actual code to draw info from the content system I
have. In neither case does the alternate text or code show up. Here is
the code in the views.py that renders the page I'm having problems
with:
from django.http import HttpResponse
from django.template import Context, loader
def Index( request ):
t = loader.get_template( 'index.html' )
c = Context( { 'title': "EasyAutoSales.com Best Car Site Ever", } )
I've tried to use "t = loader.select_template( [ 'index.html',
'index_title.html', 'index_body.html' ] )" as well without any luck.
Thanks for the quick reply!
Randall Prince
return HttpResponse( t.render( c ) )
def Index( request ):
t = loader.get_template( 'index.html' )
I'm looking at the Django Template language page (http://
www.djangoproject.com/documentation/templates/) and what it's saying
(as well as my logic) isn't meshing with what you're saying. Here's a
simple example I'm creating right now for educational purposes:
index_title.html:
{% extends "index.html" %}
{% block tag_title %}THIS IS THE TITLE{% endblock %}
index.html:
<html>
<head>
<title>{% block block_title %}THIS IS NOT THE TITLE{% endblock %}</
title>
</head>
<body>
{% block block_header %}THIS IS NOT THE HEADER{% endblock %}<br />
<br />
{% block block_body %}THIS IS NOT THE BODY{% endblock %}<br />
<br />
{% block block_footer %}THIS IS NOT THE FOOTER{% endblock %}<br />
<br />
</body>
</html>
I'm going to load the "index_title.html" file? How can I load the
proper files to extend the header, body and footer section then? It
just seems like reverse logic to me.
On Oct 22, 11:54 am, "Karen Tracey" <kmtra...@gmail.com> wrote:
So, example:
You'll write up index_viewlist.html which only has the individual
special "blocks" of code which are then used in the index.html
template (index_viewlist.html->index.html). Then, you'll have another
file called index_viewitem.html which will use the same block names to
form new code using the index.html template (index_viewitem.html-
>index.html).
I was hoping for more of a tree structure of extensions...but I see
how that would breakdown when you want to use various views to inheret
from a single index file using their own methods to put data into that
index. Long story short, it's very much akin to templated classes.
Randall Prince
On Oct 22, 12:10 pm, DjangoFett <randallpri...@gmail.com> wrote:
> How, then, can i extend multiple code sources off of my index.html
> file?
>
> I'm looking at the Django Template language page (http://www.djangoproject.com/documentation/templates/) and what it's saying
I was hoping for more of a tree structure of extensions...
Randall
On Oct 22, 12:54 pm, "Karen Tracey" <kmtra...@gmail.com> wrote:
On 10/22/07, DjangoFett <randal...@gmail.com> wrote:
>
> The more I "fiddle" with these templates, the more I'm understanding
> them. It was the initial learning curve that just had me confused b/c
> it wasn't what I was looking for...
There is a description of how template inheritance works in the no-tutorial
documentation:
http://www.djangoproject.com/documentation/templates/#template-inheritance
--
Ramiro Morales