Given the following code, can anyone explain why Django can't reverse
this, because I'm of the opinion that reverse is the flakiest function
ever:
<< models.py >>
class Post(models.Model):
"""created is a datetime object"""
@permalink
def get_absolute_url(self):
params = dict(year=self.created.year,
month=self.created.month, slug=self.slug)
return reverse('post', kwargs=params)
<< urls.py >>
urlpatterns = patterns('apps.article.views',
url(
r'^entries/(?P<year>\d{4})/(?P<month>\d{2})/(?P<slug>[-\w]+)/
$',
'entry_detail',
name='post',
),
)
I get the following error when trying to call post.get_absolute_url():
======================================================================
ERROR: tests that monkeypatch to model works
----------------------------------------------------------------------
Traceback (most recent call last):
File "./../apps/stream/tests/stream.py", line 45, in
testCreatedPatch
print article.get_absolute_url()
File "/Users/REDACTED/Projects/django/trunk/django/utils/
functional.py", line 55, in _curried
return _curried_func(*(args+moreargs), **dict(kwargs,
**morekwargs))
File "/Users/REDACTED/Library/Python/2.5/site-packages/django/db/
models/base.py", line 532, in get_absolute_url
return settings.ABSOLUTE_URL_OVERRIDES.get('%s.%s' %
(opts.app_label, opts.module_name), func)(self, *args, **kwargs)
File "/Users/REDACTED/Projects/django/trunk/django/db/models/
__init__.py", line 30, in inner
return reverse(bits[0], None, *bits[1:3])
File "/Users/REDACTED/Library/Python/2.5/site-packages/django/core/
urlresolvers.py", line 256, in reverse
*args, **kwargs)))
TypeError: reverse() argument after ** must be a dictionary
I swear it's a dictionary, so why does it always fail? It drives me
mad.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---