Calling Python function in Django template

后端 未结 4 2012
一向
一向 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:31

    Templates are deliberately not able to do such stuff. The purpose is to prevent you from putting your business logic in templates, which are meant to deal only with the layout.

    So a possible way to do this is to define a NewsletterPathLastElement(self) function in your newsletter Model, and call that from the template.

提交回复
热议问题