Could not parse the remainder: '[cat_id]' from 'menu[cat_id]'

Viewed 63

I am new to django and jinja template. I am getting below error:

Could not parse the remainder: '[cat_id]' from 'menu[cat_id]'

I am trying to create dynamic tabs in my header for product categories, below is my code where error is happening:

{% for cat_id in menu %}
    <span class="navbar-item {% if 'sub_cat' in menu[cat_id] %} has-dropdown is-hoverable{% endif %}" style="{% if 'sub_cat' in menu[cat_id] %}align-items:center{% endif %}" >

menu is the dictionary and below is the sample structure for the same:

menu = {
1: {
    'category': 'Jewellery',
    'slug': 'abc',
    'sub_cat': {
        3: {
            'category': 'Earrings',
            'slug': 'def'
        }
    }
},
2: {
    'category': 'Apparel',
    'slug': 'ghi'
}
}

I am using python version 3.8, I tried degrading it to 3.7 as well, but error is still coming.

I am not sure if changing python version helps or not.

Thanks in advance

0 Answers
Related