django template system, calling a function inside a model

前端 未结 5 919
遇见更好的自我
遇见更好的自我 2020-11-27 02:47

I want to call a function from my model at a template such as:

class ChannelStatus(models.Model):
 ..............................
 .........................         


        
5条回答
  •  孤城傲影
    2020-11-27 03:33

    Another option is to define a property. See http://adam.gomaa.us/blog/2008/aug/11/the-python-property-builtin/ .

    You write your function that can do pretty much anything you want. You make it a read only property. You call the property from the template.

    Et voilà !!!!

提交回复
热议问题