Hi
The for tag iterates over the elements of the list you are using so
your code should be
$(function() {
var data = [];
var i = something();
{% for x in content %}
data[i] =
{
roll_no: {{x.roll_no}},
I would just write a template tag that outputs the whole JS function.
templates are too limiting in what you can use in {{}} brackets.
konstantin
On Aug 15, 8:38 pm, Landy Chapman wrote:
> You may be right. I am out of my element (pardon the pun). However,
> assuming your "content" was this:
>
You may be right. I am out of my element (pardon the pun). However,
assuming your "content" was this:
content = [ { 'roll_no':1, 'cell_no': 1, 'nationality':'nation1'},
{ 'roll_no':2, 'cell_no': 2, 'nationality':'nation2'},
{ 'roll_no':3, 'cell_no': 3, 'nationality':'nation3'},
the django templ
I dont think we could even use "[]" as in
roll_no: {{content[0].roll_no}},
am i correct ?? couldnt find any reference to it on
https://docs.djangoproject.com/en/dev/topics/templates/
On Tue, Aug 16, 2011 at 5:07 AM, Landy Chapman wrote:
> @Konstantin Sushenko nice catch!
> >> as a resul
@Konstantin Sushenko nice catch!
>> as a result of this you will have a series of 'data[i] = ...'
>>assignments in your output. where 'i' would be undefined.
So could he use this: JS isn't my thing, and this is approaching
too_clever
> $(function() {
i = 0;
> var dat
okay so i temporarily removed the loop just to see if the template works
$(function() {
var data = [];
data[0] =
{
roll_no: {{content[0].roll_no}},
cell_no: {{content[0].cell_no}},
nationality:
On Aug 15, 11:45 pm, Adam Zedan wrote:
> Hi i am getting a problem with my for loop which i used in my template.Could
> you kindly let me know what is going wrong in here.
> The for loop is in a jquery function
I think this:
> {% for x in range(len(content)) %}
.. is not allowed
Ooops.. sorry for the i:
The code is
$(function() {
var data = [];
{% for x in range(len(content)) %}
data[x] =
{
roll_no: {{content[x].roll_no}},
cell_no: {{content[x].cell_no}},
hello,
as a result of this you will have a series of 'data[i] = ...'
assignments in your output. where 'i' would be undefined.
konstantin
On Aug 15, 7:45 pm, Adam Zedan wrote:
> Hi i am getting a problem with my for loop which i used in my template.Could
> you kindly let me know what is going w
9 matches
Mail list logo