假设我有一个名为credit_facilities的字典,在这个字典中,我将信贷工具id映射到它的动词表示。
credit_facilities = {1 : 'Yes',2:'No',3:'Not sure'}我有一个模型对象,我在其中检索值作为字典的键。例如,假设模型名为"customer“,并且它具有名为"credit_facility”的属性。因此,customer.credit_facility给出1、2或3。我想将此值用作字典中的键。意思是,在django模板语言中有没有一个等价物来表示下面的表达式。
credit_facilities[customer.credit_facility]https://stackoverflow.com/questions/41395999
复制相似问题