Can we pass a page name to a extends tag in django
i.e, i want to do something like
EDIT
if(login):
return render_to_response('/p_change/',
context_instance=RequestContext(request,{‘page’:’newpage.html’}))
else:
return render_to_response('/p_h/',
context_instance=RequestContext(request,{‘page’:’newpage1.html’}))
{% extends page %}
It is possible to pass a variable to
extends. From django book:However, do note that there is a caveat!
This means you’ll have to place the page selection logic in your views (and not in your template as that will come before the
extendtag hence invalidating template inheritance) and pass in the variable in your context. See this answer for more details.Update
In your updated question, your code is almost there, except that the first argument to render_to_response should be an template filename, not a directory.
I would rewrite what you have as:
Of course, I’m just speculating on what you’re trying to achieve and may well be mistaken.