我想从我的模型中的模板调用一个函数,例如:
class ChannelStatus(models.Model):
 ..............................
 ..............................
    def get_related_deltas(self,epk):
        mystring = ""
        if not self.get_error_code_delta(epk):
            return mystring
        else:
            for i in self.get_listof_outage():
                item = i.error_code.all()
                for x in item:
                    if epk == x.id:
                        mystring= mystring +" "+str(i.delta())
        return mystring         
当我想从模板中调用它时:假设在渲染时,我将channel_status_list传递为
channel_status_list = ChannelStatus.objects.all()
{% for i in channel_status_list %}
  {{ i.get_related_deltas(3) }}
{% endfor %}
这是行不通的,我可以调用一个不消耗任何东西的函数,但是如果发现有参数,就无法找到该怎么办
干杯