问题
Newbie question.
I need to extend to the user template if the user is authenticated otherwise extend the guest template.
I have the following code at the top my page.
{% if request.user.is_authenticated %}
{% extends 'users/base.html' %}
{% else %}
{% extends 'guests/base.html' %}
{% endif %}
But then I get the following error:
TemplateSyntaxError at /events/
Invalid block tag: 'else'
If I don't use extends inside the condition then it works. So i'm confuse what is wrong:
{% if request.user.is_authenticated %}
user
{% else %}
guest
{% endif %}
来源:https://stackoverflow.com/questions/23789434/django-invalid-block-tag-else