Django templates and variable attributes

后端 未结 6 558
忘掉有多难
忘掉有多难 2020-12-02 13:43

I\'m using Google App Engine and Django templates.
I have a table that I want to display the objects look something like:

Object Result:
    Items =          


        
6条回答
  •  感情败类
    2020-12-02 14:09

    I'm assuming that the part the doesn't work is {{ user.item }}.

    Django will be trying a dictionary lookup, but using the string "item" and not the value of the item loop variable. Django did the same thing when it resolved {{ user.name }} to the name attribute of the user object, rather than looking for a variable called name.

    I think you will need to do some preprocessing of the data in your view before you render it in your template.

提交回复
热议问题