I am developing a website with django and want to keep a common template for header and footer. The contents of the header and footer vary with respect to the user logged in. So is there a way where i could use:
header=render_to_response('header.html',{....})
footer=render_to_response('footer.html',{....})
content=render_to_response('content.html',{....})
return header+content+footer
Harsh, concatenating
HttpResponseobjects is not the way to do it. Django’s (and I believe, reasonable) approach recommends using templates including and inheritance. Please, take a look at{% block %},{% include %}and{% extend %}template tags here.In your case the way to implement template inheritance looks like:
base.html :
my.template.html :