I have an error message on django 1.4:
dictionary update sequence element #0 has length 1; 2 is required
[EDIT]
It happe
I too had a similar type of problem . The solution is simple . just dont try to enter NULL or None value in values or u might have to use Something like thisdic.update([(key,value)])
I got this error when I was messing around with string and dictionary.
dict1 = {'taras': 'vaskiv', 'iruna': 'vaskiv'}
str1 = str(dict1)
dict(str1)
*** ValueError: dictionary update sequence element #0 has length 1; 2 is required
So what you actually got to do to get dict from string is:
dic2 = eval(str1)
dic2
{'taras': 'vaskiv', 'iruna': 'vaskiv'}
Or in matter of security we can use literal_eval
from ast import literal_eval
I faced the above mentioned problem when I forgot to pass a keyword argument name to url() function.
Code with error
url(r"^testing/$", views.testing, "testing")
Code without error
url(r"^testing/$", views.testing, name="testing")
So finally I removed the above error in this way. It might be something different in your case. So check your url patterns in urls.py.
Pass a keyword argument name with value as your view name e.g home
or home-view
etc. to url()
function.
url(r'^home$', 'common.views.view1', 'home'),
url(r'^home$', 'common.views.view1', name='home'),
The error should be with the params. Please verify that the params is a dictionary object. If it is just a list/tuple of arguments use only one * (*params
) instead of two * (**params
). This will explode the list/tuple into the proper amount of arguments.
Or, if the params is coming from some other part of code as a JSON file, please do json.loads(params)
, because the JSON objects sometimes behave as string and so you need to make it as a JSON using load from string (loads).
super(HStoreDictionary, self).__init__(value, **params)
Hope this helps!
I encountered this issue when trying to invoke the update method with a parameter of a wrong type. The expected dict was:
{'foo': True}
The one that was passed was:
{'foo': "True"}
make sure you check all the parameters you pass are of the expected type.