ValueError: Need 2 values to unpack in for loop; got 3 (actually num_loopvars = 2 and len_item = 3)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

ValueError: Need 2 values to unpack in for loop; got 3 (actually num_loopvars = 2 and len_item = 3)

Ogi Vranesic

Hi

I have used some templates in older django versions.
But now in django 1.11 using the same templates, the error:

ValueError: Need 2 values to unpack in for loop; got 3.

will be raised on line 207 in module django.template.defaulttags
by the method render of class ForNode

Actually is by me looking at code num_loopvars = 2 and len_item = 3.

After I've outcommented this part of code, some of this template as a form is displayed and one can work on it.

So could somebody tell me what is purpose of this two variables and comparing of them?

Thanks very much in advance and best regards
Ogi


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2954a3e8-4590-64ce-1264-39c3e05b1dde%40redcor.ch.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ValueError: Need 2 values to unpack in for loop; got 3 (actually num_loopvars = 2 and len_item = 3)

Michal Petrucha-3
On Mon, Jul 17, 2017 at 03:46:30PM +0200, Ogi Vranesic wrote:

> Hi
>
> I have used some templates in older django versions.
> But now in django 1.11 using the same templates, the error:
>
> ValueError: Need 2 values to unpack in for loop; got 3.
>
> will be raised on line 207 in module django.template.defaulttags
> by the method render of class ForNode
>
> Actually is by me looking at code *num_loopvars = 2* and *len_item = 3*.
>
> After I've outcommented this part of code, some of this template as a form
> is displayed and one can work on it.
>
> So could somebody tell me what is purpose of this two variables and
> comparing of them?
>
> Thanks very much in advance and best regards
> Ogi
Sounds like you are trying to loop over a list in your template,
something like this::

    {% for a, b in mylist %}
        ...
    {% endfor %}

The problem is that mylist contains triples, not pairs. It would help
a lot if you could show the actual template code, as well as the
context that you pass to the template.

Cheers,

Michal

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/20170717140802.GD23772%40koniiiik.org.
For more options, visit https://groups.google.com/d/optout.

signature.asc (836 bytes) Download Attachment
Loading...