I am including templateInclude.html in templateA.html. While I can access {{ request.get_full_path }} from templateA.html, I cannot do so from templateInclude.html.
I would both like to solve and understand that problem. Is there a way of passing the request object to the included template?
If you are using Django version 1.3+, then you can use:
For earlier versions, you should use
withtemplatetag ie.In the both cases, just use
full_pathin the template which you will be including.In general it works like context managers in regular python code – http://www.python.org/dev/peps/pep-0343/
Anyway it’s weird because according to the docs, included templates have access to the whole context of parent template. Check if you’re using
RequestContextin the view, or as a middleware.