Closed zangguojun closed 4 years ago
That is how the django template system works. Otherwise it would be ambiguous. What if you wanted to access a key called “foo”?
Sent from my phone
On Nov 18, 2020, at 9:30 AM, zangguojun notifications@github.com wrote:
Reopened #83.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.
I want to traverse session.vars.['1']
, session.vars.['2']
, session.vars.['3'] and so on in session.vars rather than write session.vars.['1']
,session.vars.['2']
,session.vars.['3']
directly.This is too much trouble.
If you want to iterate over keys and values of a dict, use the .items method. But anyway I think you will have an easier time if you use vars_for_template to send just the data you need to the template.
Sent from my phone
On Nov 18, 2020, at 10:20 AM, zangguojun notifications@github.com wrote:
I want to traverse session.vars.['1'], session.vars.['2'], session.vars.['3'] and so on in session.vars rather than write session.vars.['1'],session.vars.['2'],session.vars.['3'] directly.This is too much trouble.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.
If you want to iterate over keys and values of a dict, use the .items method. But anyway I think you will have an easier time if you use vars_for_template to send just the data you need to the template.
Sent from my phone
On Nov 18, 2020, at 10:20 AM, zangguojun notifications@github.com wrote:
I want to traverse session.vars.['1'], session.vars.['2'], session.vars.['3'] and so on in session.vars rather than write session.vars.['1'],session.vars.['2'],session.vars.['3'] directly.This is too much trouble.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.
Thanks! But I need to pass data between APPS, which should be the best way to do it.
models.py -->Group Constants.num_rounds == 10
------------------------> output:
In one test page: I want do this,
but error
**session has no attribute "vars.1.foo"**
It doesn't seem to recognizefoo
as1
What should I do?? Looking forward to hearing from you and thanks!