ValueError too many values to unpack

Raised by:

django/forms/widgets.py (line 530)

Traceback (most recent call last):
  File "python2.7/site-packages/django/core/handlers/base.py", line 137, in get_response
    response = response.render()
  File "python2.7/site-packages/django/template/response.py", line 103, in render
    self.content = self.rendered_content
  File "python2.7/site-packages/django/template/response.py", line 80, in rendered_content
    content = template.render(context)
  File "python2.7/site-packages/django/template/base.py", line 148, in render
    return self._render(context)
  File "python2.7/site-packages/django/template/base.py", line 142, in _render
    return self.nodelist.render(context)
  File "python2.7/site-packages/django/template/base.py", line 844, in render
    bit = self.render_node(node, context)
  File "python2.7/site-packages/django/template/debug.py", line 80, in render_node
    return node.render(context)
  File "python2.7/site-packages/django/template/loader_tags.py", line 126, in render
    return compiled_parent._render(context)
  File "python2.7/site-packages/django/template/base.py", line 142, in _render
    return self.nodelist.render(context)
  File "python2.7/site-packages/django/template/base.py", line 844, in render
    bit = self.render_node(node, context)
  File "python2.7/site-packages/django/template/debug.py", line 80, in render_node
    return node.render(context)
  File "python2.7/site-packages/django/template/loader_tags.py", line 65, in render
    result = block.nodelist.render(context)
  File "python2.7/site-packages/django/template/base.py", line 844, in render
    bit = self.render_node(node, context)
  File "python2.7/site-packages/django/template/debug.py", line 80, in render_node
    return node.render(context)
  File "python2.7/site-packages/django/template/loader_tags.py", line 65, in render
    result = block.nodelist.render(context)
  File "python2.7/site-packages/django/template/base.py", line 844, in render
    bit = self.render_node(node, context)
  File "python2.7/site-packages/django/template/debug.py", line 80, in render_node
    return node.render(context)
  File "python2.7/site-packages/django/template/loader_tags.py", line 65, in render
    result = block.nodelist.render(context)
  File "python2.7/site-packages/django/template/base.py", line 844, in render
    bit = self.render_node(node, context)
  File "python2.7/site-packages/django/template/debug.py", line 80, in render_node
    return node.render(context)
  File "python2.7/site-packages/django/template/debug.py", line 90, in render
    output = self.filter_expression.resolve(context)
  File "python2.7/site-packages/django/template/base.py", line 596, in resolve
    obj = self.var.resolve(context)
  File "python2.7/site-packages/django/template/base.py", line 734, in resolve
    value = self._resolve_lookup(context)
  File "python2.7/site-packages/django/template/base.py", line 788, in _resolve_lookup
    current = current()
  File "python2.7/site-packages/django/forms/forms.py", line 275, in as_p
    errors_on_separate_row=True)
  File "python2.7/site-packages/django/forms/forms.py", line 219, in _html_output
    'field': six.text_type(bf),
  File "python2.7/site-packages/django/forms/forms.py", line 508, in __str__
    return self.as_widget()
  File "python2.7/site-packages/django/forms/forms.py", line 560, in as_widget
    return force_text(widget.render(name, self.value(), attrs=attrs))
  File "python2.7/site-packages/django/forms/widgets.py", line 504, in render
    options = self.render_options(choices, [value])
  File "python2.7/site-packages/django/forms/widgets.py", line 530, in render_options
    for option_value, option_label in chain(self.choices, choices):
ValueError: too many values to unpack

How to reproduce

example_field = forms.ChoiceField(label=u'Example', choices=[u'Choice 1', 'Choice 2'])

How to fix

This is wrong:
example_field = forms.ChoiceField(label=u'Example', choices=[u'Choice 1', 'Choice 2'])

The correct is to specify choices as a iterable of iterables (like a list of tuples), because the expected format is like [(value, text), (value2, text2)].

So, for the above, the correct version is:
example_field = forms.ChoiceField(label=u'Example', choices=[(1, u'Choice 1'), (2, 'Choice 2')])

For more info see (those are docs for models, but the principle used for choices is the same): https://docs.djangoproject.com/en/1.7/ref/models/fields/#field-choices