title: Error: "dictionary update sequence element #0 has length 1; 2 is required" on Django 1.4
body: <p>I have an error message on Django 1.4:</p>
  <pre><code>dictionary update sequence element #0 has length 1; 2 is required
  </code></pre>
  <p>It happened when I tried using a template tag like: <code>{% for v in values %}</code>:</p>
  <pre><code>dictionary update sequence element #0 has length 1; 2 is required
  
  Request Method:     GET
  Request URL:    ...
  Django Version:     1.4.5
  Exception Type:     ValueError
  Exception Value:    
  
  dictionary update sequence element #0 has length 1; 2 is required
  
  Exception Location:     /usr/local/lib/python2.7/dist-packages/djorm_hstore/fields.py in __init__, line 21
  Python Executable:  /usr/bin/uwsgi-core
  Python Version:     2.7.3
  Python Path:    
  
  ['/var/www/',
   '.',
   '',
   '/usr/lib/python2.7',
   '/usr/lib/python2.7/plat-linux2',
   '/usr/lib/python2.7/lib-tk',
   '/usr/lib/python2.7/lib-old',
   '/usr/lib/python2.7/lib-dynload',
   '/usr/local/lib/python2.7/dist-packages',
   '/usr/lib/python2.7/dist-packages',
   '/usr/lib/python2.7/dist-packages/PIL',
   '/usr/lib/pymodules/python2.7']
  
  Server time:    sam, 13 Jul 2013 16:15:45 +0200
  Error during template rendering
  
  In template /var/www/templates/app/index.html, error at line 172
  dictionary update sequence element #0 has length 1; 2 is required
  
  172     {% for product in products %}
  
  Traceback Switch to copy-and-paste view
  
  /usr/lib/python2.7/dist-packages/django/core/handlers/base.py in get_response
  
                              response = callback(request, *callback_args, **callback_kwargs)
  
      ...
  ▶ Local vars
  /usr/lib/python2.7/dist-packages/django/contrib/auth/decorators.py in _wrapped_view
  
                      return view_func(request, *args, **kwargs)
  
      ...
  ▶ Local vars
  /usr/lib/python2.7/dist-packages/django/views/decorators/http.py in inner
  
                  return func(request, *args, **kwargs)
  
      ...
  ▶ Local vars
  ./app/views.py in index
  
              context_instance=RequestContext(request))
  
      ...
  ▶ Local vars
  /usr/lib/python2.7/dist-packages/django/shortcuts/__init__.py in render_to_response
  
          return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
  
      ...
  ▶ Local vars
  /usr/lib/python2.7/dist-packages/django/template/loader.py in render_to_string
  
              return t.render(context_instance)
  
      ...
  ▶ Local vars
  /usr/lib/python2.7/dist-packages/django/template/base.py in render
  
                  return self._render(context)
  
      ...
  ▶ Local vars
  /usr/lib/python2.7/dist-packages/django/template/base.py in _render
  
              return self.nodelist.render(context)
  
      ...
  ▶ Local vars
  /usr/lib/python2.7/dist-packages/django/template/base.py in render
  
                      bit = self.render_node(node, context)
  
      ...
  ▶ Local vars
  /usr/lib/python2.7/dist-packages/django/template/debug.py in render_node
  
                  return node.render(context)
  
      ...
  ▶ Local vars
  /usr/lib/python2.7/dist-packages/django/template/loader_tags.py in render
  
              return compiled_parent._render(context)
  
      ...
  ▶ Local vars
  /usr/lib/python2.7/dist-packages/django/template/base.py in _render
  
              return self.nodelist.render(context)
  
      ...
  ▶ Local vars
  /usr/lib/python2.7/dist-packages/django/template/base.py in render
  
                      bit = self.render_node(node, context)
  
      ...
  ▶ Local vars
  /usr/lib/python2.7/dist-packages/django/template/debug.py in render_node
  
                  return node.render(context)
  
      ...
  ▶ Local vars
  /usr/lib/python2.7/dist-packages/django/template/loader_tags.py in render
  
                  result = block.nodelist.render(context)
  
      ...
  ▶ Local vars
  /usr/lib/python2.7/dist-packages/django/template/base.py in render
  
                      bit = self.render_node(node, context)
  
      ...
  ▶ Local vars
  /usr/lib/python2.7/dist-packages/django/template/debug.py in render_node
  
                  return node.render(context)
  
      ...
  ▶ Local vars
  /usr/lib/python2.7/dist-packages/django/template/defaulttags.py in render
  
              len_values = len(values)
  
      ...
  ▶ Local vars
  /usr/lib/python2.7/dist-packages/django/core/paginator.py in __len__
  
              return len(self.object_list)
  
      ...
  ▶ Local vars
  /usr/lib/python2.7/dist-packages/django/db/models/query.py in __len__
  
                      self._result_cache = list(self.iterator())
  
      ...
  ▶ Local vars
  /usr/lib/python2.7/dist-packages/django/db/models/query.py in iterator
  
                          obj = model(*row[index_start:aggregate_start])
  
      ...
  ▶ Local vars
  /usr/lib/python2.7/dist-packages/django/db/models/base.py in __init__
  
                      setattr(self, field.attname, val)
  
      ...
  ▶ Local vars
  /usr/local/lib/python2.7/dist-packages/djorm_hstore/fields.py in __set__
  
                  value = self.field._attribute_class(value, self.field, obj)
  
      ...
  ▶ Local vars
  /usr/local/lib/python2.7/dist-packages/djorm_hstore/fields.py in __init__
  
              super(HStoreDictionary, self).__init__(value, **params)
  
      ...
  ▶ Local vars
  </code></pre>
  <p>It happens too when I try to access on a hstore queryset:</p>
  <pre><code>Traceback (most recent call last):
  File &quot;manage.py&quot;, line 14, in &lt;module&gt;
      execute_manager(settings)
  
  File &quot;/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py&quot;, line 459, in execute_manager
      utility.execute()
  
  File &quot;/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py&quot;, line 382, in execute
      self.fetch_command(subcommand).run_from_argv(self.argv)
  
  File &quot;/usr/local/lib/python2.7/dist-packages/django/core/management/base.py&quot;, line 196, in run_from_argv
      self.execute(*args, **options.__dict__)
  
  File &quot;/usr/local/lib/python2.7/dist-packages/django/core/management/base.py&quot;, line 232, in execute
      output = self.handle(*args, **options)
  
  File &quot;/home/name/workspace/project/app/data/commands/my_command.py&quot;, line 60, in handle
      item_id = tmp[0].id,
  
  File &quot;/usr/local/lib/python2.7/dist-packages/django/db/models/query.py&quot;, line 207, in __getitem__
      return list(qs)[0]
  
  File &quot;/usr/local/lib/python2.7/dist-packages/django/db/models/query.py&quot;, line 87, in __len__
      self._result_cache.extend(self._iter)
  
  File &quot;/usr/local/lib/python2.7/dist-packages/django/db/models/query.py&quot;, line 301, in iterator
      obj = model(*row[index_start:aggregate_start])
  
  File &quot;/usr/local/lib/python2.7/dist-packages/django/db/models/base.py&quot;, line 300, in __init__
      setattr(self, field.attname, val)
  
  File &quot;/usr/local/lib/python2.7/dist-packages/djorm_hstore/fields.py&quot;, line 38, in __set__
      value = self.field._attribute_class(value, self.field, obj)
  
  File &quot;/usr/local/lib/python2.7/dist-packages/djorm_hstore/fields.py&quot;, line 21, in __init__
      super(HStoreDictionary, self).__init__(value, **params)
  
  ValueError: dictionary update sequence element #0 has length 1; 2 is required
  </code></pre>
  <p>The code is:</p>
  <pre><code>tmp = Item.objects.where(HE(&quot;kv&quot;).contains({'key':value}))
  
  if tmp.count() &gt; 0:
              
      item_id = tmp[0].id,
  </code></pre>
  <p>I'm just trying to access the value.  I don't understand the &quot;update sequence&quot; message.  When I use a cursor instead of <code>hstore queryset</code>,  the function works. The error comes on template rendering too.  I just restarted <code>uwsgi</code> and everything works well, but the error comes back later.</p>