Django - Why am I getting TemplateSyntaxError?
Asked Answered
B

1

8

I have included a new app django_colorbox in my Pinax project. For some reason the following code throw TemplateSystaxError: Invalid block tag: 'include_colorbox', expected 'endblock' or 'endblock extra_head'.

{% block extra_head %} <!-- Defined in base html template -->
    {% include_colorbox %} <!-- Simple tag defined in django_colorbox -->
{% endblock %}

The source code for the errand simple tag is - https://github.com/aljosa/django-colorbox/blob/master/django_colorbox/templatetags/colorbox_tags.py.

If I can embedded other build-in tags (e.g. blocktrans) inside block then why not the custom simple tags?

Brinkmanship answered 5/3, 2012 at 19:30 Comment(0)
S
27

You need to have {% load colorbox_tags %} in every template where you use one of the tags.

Sclar answered 5/3, 2012 at 20:9 Comment(1)
TIL. For anybody else coming here from google like I did, this applies just as readily when you want to use {% static 'somefile' %}; every template must contain {% load staticfiles %} even if it extends a template that already contains that.Rodmun

© 2022 - 2024 — McMap. All rights reserved.