Exactly what the question says. I have three templates base.html, logged_in_base.html, and page.html. I want page.html to extend base.html when the user isn't logged in and to extend logged_in_base.html when the user is logged in. How do I do this?
(This is basically because I have a different navbar for logged in users and not logged in users.)
Since
{% extends %}needs to be the first statement in a template, one cannot put the logic in the template.But one can put the logic in the view since
{% extends %}can work with a variable:views.py
page.html
An alternative solution could be a single base template and conditional statement to decide which navigation bar to use.