Login

Tag "tuple"

Snippet List

Retrieve human-readable value from choices tuple or value from dict

Will help you retrieve the value from a dictionary with a supplied key, or the human-readable value from a choices tuple. Works as follows: To retrieve the value of a dict: `{{ crime_rates_dict|getval:"Chicago" }}` <-- will return value of `crime_rates_dict["Chicago"]` To retrieve the human-readable value from a choices tuple: `{{ country.COUNTRIES|getval:"US" }}` <-- will return "United States" in `COUNTRIES = (("US", "United States"),)`

  • template
  • templatetag
  • choices
  • dict
  • tuple
Read More

1 snippet posted so far.