Calling Python function in Django template

后端 未结 4 2011
一向
一向 2021-02-09 12:52

Inside a django template I\'m trying to call the split function on one of the template variables and then get the last element, so I did something like this:

{{          


        
4条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-09 13:37

    From the django book:

    Note that you do not include parentheses in the method calls. Also, it’s not possible to pass arguments to the methods; you can only call methods that have no required arguments.

    So, if you want to call a method without arguments from a template, it's fine. Otherwise, you have to do it in the view.

提交回复
热议问题