Karen,
Thanks for your help. That was just a simplified example to show my
point but your suggestion was the problem I was facing.
Jon
On Dec 7, 11:54 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Dec 6, 2007 1:43 PM, JLathem <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > I have a template that extends another. Each template have variables
> > in them. When the variable in the parent template changes the HTML is
> > not updated. That is to say, a variable in the parent page is set to
> > X I view the page for the first time and I see X. The vale of the
> > variable changes to Y. I view the page and I see X. I am not using
> > any Django caching libraries and I clear my browser cache in between
> > invocations of the page. I am using Apache, Mod_Python, and trunk of
> > the Django SVN. Below is a small example that demonstrates what I am
> > talking about.
>
> > ------------urls.py (snippet)------------
> > (r'^test/$', 'django.views.generic.simple.direct_to_template',
> > {'extra_context':{"var":datetime.datetime.now(),
> > "var2":datetime.datetime.now().second}, 'template':'test2.html'}),
>
> > ------------test1.html------------
> > {{var2}}|{%block rep%}{%endblock%}
>
> > ------------test2.html------------
> > {%extends "test1.html"%}{%block rep%}{{var}}{%endblock%}
>
> > Is this problem caused by the caching of parsed templates? Should
> > parent pages not contain variables? Thanks for any help you guys can
> > give me.
>
> This has nothing to do with caching. The code in your urls.py that sets
> var and var2 is executed only once, when urls.py is first imported. This
> code does not get re-executed every time urls.py is consulted for url
> matching. This is just how Python works. Note as described here:
>
> http://www.djangoproject.com/documentation/generic_views/
>
> in the description of extra_context, the values you specify may be
> functions. These functions are then evaluated just before they are passed
> to the template. This is the approach you need to use for passing current
> time information.
>
> Karen
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---