I'm 2 hours into Django and am wondering if there is a way to specify a default base template that will automatically be loaded for all templates so that you don't have to repeat yourself and specify {% extends "foo.html" %}
at the top of every page template.
For example, at the project or app level some metadata(settings) could specify a default template that was used unless either the call to render or the template itself specified that you shouldn't include the template.
i. e. render(... other args..., layout=null)
or {% noextends "foo.html" %}
This effectively turns the opt-in style into an opt-out, which in my experience is preferred. Given that it's specified in something like settings it's not "magic" and breaking with the spirit of Django.
I've looked over the documentation and this doesn't seem to be available by default. I suppose I could do something like override the built-in render routine to try and concatenate the {% extends "foo.html" %}
call on to every template, but I am hoping the internet can just tell me there is already a solution that I'm missing.
Unless you want to write your own template loader function that looks to your settings for the default and monkey-patch it in, then "no, there isn't a way to do that" is accurate.
At least it's only one line per file.
Plus, being a long-standing Django convention, other devs will immediately be able to see which base template is used (in more complex projects you may find you use different base templates depending on, say, the type of user).
Finally, as the Zen of Python goes, explicit is better than implicit. :-)