extends should always be on first line of file and it accepts a variable as
argument so you can define which template should be used on your view.

# views.py
def home(request):
    if request.session.type == 1:
         base = 'base.html'
    else:
        base = 'base_other.html'

    context = {
        'base': base,
    }

    return render(request, 'template.html', context)

# template.html
{% extends base %}

if you need it on every template maybe you should use a context processor
to define your base variable.

2015-05-13 15:11 GMT-03:00 carlos <[email protected]>:

> Hi, is posible change my base template with if tag
> example:
>
> {% if request.session.type = '1' %}
>     {% extends "base.html"%}
> {% else %}
>    {% extends "base_other.html"%}
> {%endif%}
>
> i have a error like that
>
> TemplateSyntaxError at /monito/cult/
>
> Invalid block tag: 'endif'
>
>
> will to do change the base template my app
>
> Cheers
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAM-7rO3DONtDe_d%2BHeBef446Mr%3DvSiKK7z_W8pyNyPq7Pbt3PA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAM-7rO3DONtDe_d%2BHeBef446Mr%3DvSiKK7z_W8pyNyPq7Pbt3PA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAL6LtmfZTMpfG%3Djh_uMtp63hZ%2BDsmz92_8UP81x0zuGfqp%2BO0w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to