How to set a value of a variable inside a template code?

后端 未结 9 1274
我寻月下人不归
我寻月下人不归 2020-11-27 09:55

Say I have a template


Hello {{name}}!

While testing it, it would be useful to define the

9条回答
  •  萌比男神i
    2020-11-27 10:22

    In your template you can do like this:

    {% jump_link as name %}
    {% for obj in name %}
        
    {{obj.helo}} - {{obj.how}}
    {% endfor %}

    In your template-tags you can add a tag like this:

    @register.assignment_tag
    def jump_link():
        listArr = []
        for i in range(5):
            listArr.append({"helo" : i,"how" : i})
        return listArr
    

提交回复
热议问题