Search code examples
djangodjango-templatesdjango-autocomplete-light

Invalid block tag: 'get_map_layout', expected 'elif', 'else' or 'endif'


I'm facing a well known TemplateSyntaxError. It's a widget made using django-autocomplete-light. This is the part of the if statement that's rising TemplateSyntaxError`

<div id="abstract_map" class="tasky_wall_style careers">
    <h1>
        What our interns saying
    </h1>
    <div class="blue_links global_map">
        <div class="review_container">
            {% if selected_layout %}
            {% get_map_layout layout=selected_layout %}
            {% endif %}
        </div>
    </div>
</div>

And the error:

Invalid block tag: 'get_map_layout', expected 'elif', 'else' or 'endif'

I have tried to {% load get_map_layout %} in template but other error is risen 'get_map_layout' is not a valid tag library:....

Can someone help me understand what is going on so I can solve this.


Solution

  • According to the last comment I think you are just loading it by the wrong name. Instead of {% load get_map_layout %} try {% load reviews %} on top of your template.

    Django resolves custom template tags through the name of the Python module they are defined in (reviews/templatetags/reviews.py in that case), so {% load reviews %} should make all template tags defined in reviews.py available in your template.