4 ms·
do you have any code examples you'd be able to share that uses the base_template thing?
by greenie_beans 4y ago
do you have any code examples you'd be able to share that uses the base_template thing?
- pphysch 4y agoSure, Django docs say this about custom context processors: https://docs.djangoproject.com/en/4.1/ref/templates/api/#writing-your-own-context-processors https://docs.djangoproject.com/en/4.1/ref/templates/api/#wri... So in my context_processors.py file, I write something like: def base_template(request): template = "templates/base.html" # full page if "HX-Request" in request.headers: template = "templates/base_ajax.html" # minimal template return {"base_template": template} And then my template just needs to start with `{% extends base_template %}`. Nothing needs to be done in the view (although you could technically override "base_template" there, if you need to).