简体   繁体   中英

Error when passing 2 variables in template, django

I have the following view

@login_required
def myview(request):
    my_strings = ['0','1','2','3','4','5']
    var ='12'
    return render(request,
                  'index.html',{'my_strings':my_strings}, {'var': var })

But when I try to display {{ my_strings|random }} and {{ var }} variables in index.html template I get an error message:

'dict' object has no attribute 'push'

Is there any way to solve this?

You need to pass all the values in the same dict.

return render(request,
              'index.html', {'my_strings': my_strings, 'var': var })

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM