Value Error during 1.2 to 1.4 conversion

111 views
Skip to first unread message

Peter

unread,
Oct 7, 2012, 9:14:01 AM10/7/12
to django...@googlegroups.com
I'm trying to convert a Django 1.2 site to a 1.4 site.  So there's lots of changing old generic views to class-based generic views, and the apps all go up one level so lots of changes to imports, but in each case so far it's it's been quite easy to narrow down the problem to a line in my code, and fix it.  Until I got to this:

ValueError at /

dictionary update sequence element #0 has length 1; 2 is required
Request Method: GET
Request URL: http://www.crompton-saage.com/
Django Version: 1.4.1
Exception Type: ValueError
Exception Value:
dictionary update sequence element #0 has length 1; 2 is required
Exception Location: /home/cassidy/webapps/crompton/lib/python2.7/django/core/urlresolvers.py in resolve, line 207
Python Executable: /usr/local/bin/python
Python Version: 2.7.3
Python Path:
['/home/cassidy/webapps/crompton',
 '/home/cassidy/webapps/crompton/crompton',
 '/home/cassidy/webapps/crompton/lib/python2.7',
 '/usr/local/lib/python27.zip',
 '/usr/local/lib/python2.7',
 '/usr/local/lib/python2.7/plat-linux2',
 '/usr/local/lib/python2.7/lib-tk',
 '/usr/local/lib/python2.7/lib-old',
 '/usr/local/lib/python2.7/lib-dynload',
 '/usr/local/lib/python2.7/site-packages',
 '/usr/local/lib/python2.7/site-packages/PIL']
Server time: Sun, 7 Oct 2012 19:03:37 +0800

Request URL: http://www.crompton-saage.com/

Django Version: 1.4.1
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'django.contrib.admindocs',
 'django.contrib.comments',
 'django.contrib.flatpages',
 'accounts',
 'machines',
 'sales')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware')


Traceback:
File "/home/cassidy/webapps/crompton/lib/python2.7/django/core/handlers/base.py" in get_response
  101.                             request.path_info)
File "/home/cassidy/webapps/crompton/lib/python2.7/django/core/urlresolvers.py" in resolve
  300.                     sub_match = pattern.resolve(new_path)
File "/home/cassidy/webapps/crompton/lib/python2.7/django/core/urlresolvers.py" in resolve
  207.             kwargs.update(self.default_args)

Exception Type: ValueError at /
Exception Value: dictionary update sequence element #0 has length 1; 2 is required

So basically I have have no clue what part of *my* code could be causing this as there's no reference to my code.  How would I find out how to trace this back to something I can change.  I imagine I can pore through the Django sources but I'm not really a Python programmer, I just know enough syntax to write Django code.

Any ideas?

Marek Brzóska

unread,
Oct 8, 2012, 7:46:37 AM10/8/12
to django...@googlegroups.com
Check your urls.

For me it looks like you wanted to give name to the url but forgot use keyword argument. For example you could be having:

url(r"^#", "your_view", "name_of_the_view")
instead of
url(r"^#", "your_view", name="name_of_the_view")

--
Marek Brzóska

brzosk...@gmail.com

Peter

unread,
Oct 10, 2012, 8:36:08 PM10/10/12
to django...@googlegroups.com
Thanks. That pointed me in the right direction. First, I didn't realize that the 'url' form required named parameters. However, I was using the non-url form, and it turned out in the conversion to class-based generics, I had left off the "{}" third object in each list. So it was expecting a dictionary and getting a string!

Problem solved.

Reply all
Reply to author
Forward
0 new messages