I am trying to do the following.
The counter loop must go through a loop for all values, and there cannot be a user associated with each quantity, but the count value imust be used in each loop to jump to JavaScript.
part of python:
users = {}
users[1]={}
users[1][id]=...
users[1][email]=...
...
count=[1,2,3,4,5,6,7,8,9,10]
Part of the Django template:
{% for i in count %}
do some stuff with the value i using {{i}} which always returns the value, i.e. 1
email:{% if users.i.email %}'{{users.i.email}}'{% else %}null{% endif%}
{% endfor %}
This does not return anything for email. When I substitute a number 1for iin {% if user.i.email %}, email returns the email address of users. I use data in JavaScript, so it must be implicitly null if it does not exist. I cannot get Django to recognize a variable ias a variable instead of the value of i.
[] ,
email:{% if users.[i].email %}'{{users.[i].email}}'{% else %}null{% endif%}
<with
{% for i in count %}{% with current_user=users.i %}...
current_user.email,
{% for i in count %}{% with j=i.value %}...
, , j, .
inner for, , /, .
, Django i ?
Jayd
* Edit:
, , .
{% for i in count %}
{% for key, current_user in users.items %}
do some stuff with the value i using {{i}} which always returns the value, i.e. 1
email:{% if i == key and current_user.email %}'{{current_user.email}}'{% else %}null{% endif%}
{% endfor %}
{% endfor %}
, do some stuff with the value i . if if:
{% for i in count %}
{% for key, current_user in users.items %}
{% if i == key %}
do some stuff with the value i using {{i}} which always returns the value, i.e. 1
email:{% if i == key and current_user.email %}'{{current_user.email}}'{% else %}null{% endif%}
{% endif%}
{% endfor %}
{% endfor %}
, .
, current_user.
{% for i in count %}
do some stuff with the value i using {{i}} which always returns the value, i.e. 1
email:{% for key, current_user in users.items %}{% if i == key and current_user.email %}'{{current_user.email}}'{% else %}null{% endif%}{% endfor %}
{% endfor %}
.
?
, , , , i :
{% with current_user=users|getuser:i %}
, , , i "i" .
.
* Edit
.
{{}}, , {% %}
.