﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
10151	url tag causes TypeError: dict objects are unhashable	pclerie	nobody	"I'm trying out the examples in Practical Django Projects. When using named views with the url tag I get a TypeError: dict objects are unhashable (see the traceback below). The interesting thing is that it only happens _once_, the first time through. On following passes no problem occurs. I have reproduced the same behaviour with django.core.urlresolvers.reverse.

It seems I can work around this by putting a call to reverse in a try...except block in an {{{__init__.py.}}} That forces the first error and then no more problems.

Thanks

Philippe

=================

Traceback follows:
{{{
Environment:

Request Method: GET
Request URL: http://denebola.logisys.ht:8000/blog/
Django Version: 1.0.2 final
Python Version: 2.5.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'django.contrib.flatpages',
 'coltrane',
 'tagging']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')


Template error:
In template /home/philippe/prj/django/templates/base.html, error at line 33
   Caught an exception while rendering: dict objects are unhashable
   23 : 

   24 : <div id=""header"">

   25 :   <div id=""logo"">

   26 :   </div>

   27 :   <h1>L'iconoclaste</h1>

   28 :   <h5>Élucubrations d'un étranger chez lui.</h5>

   29 : </div>

   30 : 

   31 : <div id=""menu"">

   32 :   <ul>

   33 :     <li><a href="" {% url coltrane_entry_archive_index %} "">Accueil</a>

   34 :     {% block menu %}

   35 :     {% endblock %}

   36 :   </ul>

   37 : </div>

   38 : 

   39 : <div id=""main"">

   40 :   <div id=""leftcol"">

   41 :     <div id=""navigation"">

   42 :       <h4>Navigation</h4>

   43 :       <ul>

Traceback:
File ""/var/lib/python-support/python2.5/django/core/handlers/base.py"" in get_response
  86.                 response = callback(request, *callback_args, **callback_kwargs)
File ""/var/lib/python-support/python2.5/django/views/generic/date_based.py"" in archive_index
  49.     return HttpResponse(t.render(c), mimetype=mimetype)
File ""/var/lib/python-support/python2.5/django/template/__init__.py"" in render
  176.         return self.nodelist.render(context)
File ""/var/lib/python-support/python2.5/django/template/__init__.py"" in render
  768.                 bits.append(self.render_node(node, context))
File ""/var/lib/python-support/python2.5/django/template/debug.py"" in render_node
  71.             result = node.render(context)
File ""/var/lib/python-support/python2.5/django/template/loader_tags.py"" in render
  97.         return compiled_parent.render(context)
File ""/var/lib/python-support/python2.5/django/template/__init__.py"" in render
  176.         return self.nodelist.render(context)
File ""/var/lib/python-support/python2.5/django/template/__init__.py"" in render
  768.                 bits.append(self.render_node(node, context))
File ""/var/lib/python-support/python2.5/django/template/debug.py"" in render_node
  71.             result = node.render(context)
File ""/var/lib/python-support/python2.5/django/template/loader_tags.py"" in render
  97.         return compiled_parent.render(context)
File ""/var/lib/python-support/python2.5/django/template/__init__.py"" in render
  176.         return self.nodelist.render(context)
File ""/var/lib/python-support/python2.5/django/template/__init__.py"" in render
  768.                 bits.append(self.render_node(node, context))
File ""/var/lib/python-support/python2.5/django/template/debug.py"" in render_node
  81.             raise wrapped

Exception Type: TemplateSyntaxError at /blog/
Exception Value: Caught an exception while rendering: dict objects are unhashable

Original Traceback (most recent call last):
  File ""/var/lib/python-support/python2.5/django/template/debug.py"", line 71, in render_node
    result = node.render(context)
  File ""/var/lib/python-support/python2.5/django/template/defaulttags.py"", line 373, in render
    url = reverse(self.view_name, args=args, kwargs=kwargs)
  File ""/var/lib/python-support/python2.5/django/core/urlresolvers.py"", line 254, in reverse
    *args, **kwargs)))
  File ""/var/lib/python-support/python2.5/django/core/urlresolvers.py"", line 227, in reverse
    possibilities = self.reverse_dict.getlist(lookup_view)
  File ""/var/lib/python-support/python2.5/django/core/urlresolvers.py"", line 161, in _get_reverse_dict
    for name in pattern.reverse_dict:
  File ""/var/lib/python-support/python2.5/django/core/urlresolvers.py"", line 169, in _get_reverse_dict
    self._reverse_dict.appendlist(pattern.callback, (bits, p_pattern))
  File ""/var/lib/python-support/python2.5/django/core/urlresolvers.py"", line 130, in _get_callback
    self._callback = get_callable(self._callback_str)
  File ""/var/lib/python-support/python2.5/django/utils/functional.py"", line 128, in wrapper
    if mem_args in cache:
TypeError: dict objects are unhashable
}}}
"		closed	Uncategorized	1.0		worksforme			Unreviewed	0	0	0	0	0	0
