The Django template traverses the value of the b dictionary with the key, of the a dictionary

        "sku": {
            "20509": ["28314", "28315", "28316", "28317", "6145171"],
            "1627207": ["28324", "28326", "28341", "28320"]
        },
        "sku_map": {
            "20509": "",
            "28314": "S",
            "28315": "M",
            "28316": "L",
            "28317": "XL",
            "6145171": "2XL",
            "1627207": "",
            "28324": "",
            "28326": "",
            "28341": "",
            "28320": ""
        },

I want to use the key value of the sku dictionary to display the sku_map values on the template. Can the template syntax of Django be implemented? Or do you need to pass it on view?

Mar.04,2021

  1. Custom filter
from django import template

register = template.Library()


@register.filter()
def hash(h, key):
    if key in h:
        return h[key]
    else:
        return None
  1. template calls
{{ sku_map|hash:key }}

reference: https://stackoverflow.com/que.

https://docs.djangoproject.co.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3471f-2bf0e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3471f-2bf0e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?