[Fixed]-Append to site <title> in Django template using block.super

3πŸ‘

βœ…

I don’t think this is possible. Just for your specific problem I guess it can be solves if you would place the site name before the block, and use the block just to append something to the site name.

Otherwise you could define SITE_NAME in your settings.py and have a context processor like

from django.conf import settings
def site_name(request):
    return {'SITE_NAME': settings.SITE_NAME}

so that you can use {{ SITE_NAME }} in your templates – this could make sense because the site name could be usefule at other places too…

8πŸ‘

Note, Django 1.2.3 seems to already do what you want. Assuming SITE_NAME is exposed via a context_preprocessor like lzerscience illustrates, block.super should expose it through all the layers of inheritance.

main.html

{% extends "default.html" %}
{% block title %} {{ block.super }} - MAIN{% endblock %}

That displays the title β€œSITE NAME – SECTION NAME – MAIN” for me.

πŸ‘€Cerin

2πŸ‘

Django 1.6.6

{{ block.super.super }} – possible

I try now – worked πŸ™‚
But not officially …

πŸ‘€Oleksandr

Leave a comment