i have a django template – one that is normally loaded via a standard get request. However, i would also like to use this template for an ajax get.
I know i can use request.is_ajax to distinguish the call, and thus work out which page i should serve – what i don’t know is how to avoid replication.
The problem is, the page extends a base htm file – one that has all the bells and whistles (you know, header, menu et al). I don’t want this to appear in the ajax page though! What i’d like there is for the page to appear, not extending base htm
I can only think that perhaps i have two files – one that has just the contents (ajax version) and another that extends base htm, and somehow imports (not extends) the first file…
any ides how i’d do the above, or how i am meant to solve this generally?
In addition to @Daniel response, you can use yesno template filter if you have
requestin context processors, e.g.This line should be in every template you use for both page and ajax content.