Re: get_absolute_url is returning '' instead of url
On Fri, Sep 14, 2012 at 2:05 PM, Lachlan Musicman <datakid@gmail.com> wrote:
> On Fri, Sep 14, 2012 at 1:38 PM, Russell Keith-Magee
>> Something is going wrong in the reversing process, which is raising an
>> exception, which is silently swallowed by the get_absolute_url call.
>> The usual culprit is that either the URL pattern isn't matching what
>> you think, or the object values you're passing into the reversal
>> process aren't what you think they are.
>>
>> My suggestion -- open up a shell, and try making manual calls to
>> reverse(). This will show you whether the problem is with the URL
>> pattern, or with the data from the object.
Ok, this is what I got from where I'm up to in my learn-djshell-quickly:
>>> s = Session.objects.filter(slug='mechanical-tools-morning-2').get(date=datetime.date.today)
>>> s.session_number
u'1'
>>> s.date
datetime.date(2012, 9, 14)
>>> s.slug
u'mechanical-tools-morning-2'
>>> s.get_absolute_url()
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/datakid/src/envs/mlhrd/local/lib/python2.7/site-packages/django/utils/functional.py",
line 11, in _curried
return _curried_func(*(args+moreargs), **dict(kwargs, **morekwargs))
File "/home/datakid/src/envs/mlhrd/local/lib/python2.7/site-packages/django/db/models/base.py",
line 883, in get_absolute_url
return settings.ABSOLUTE_URL_OVERRIDES.get('%s.%s' %
(opts.app_label, opts.module_name), func)(self, *args, **kwargs)
File "/home/datakid/src/envs/mlhrd/local/lib/python2.7/site-packages/django/db/models/__init__.py",
line 35, in inner
return reverse(bits[0], None, *bits[1:3])
File "/home/datakid/src/envs/mlhrd/local/lib/python2.7/site-packages/django/core/urlresolvers.py",
line 476, in reverse
return iri_to_uri(resolver._reverse_with_prefix(view, prefix,
*args, **kwargs))
File "/home/datakid/src/envs/mlhrd/local/lib/python2.7/site-packages/django/core/urlresolvers.py",
line 396, in _reverse_with_prefix
"arguments '%s' not found." % (lookup_view_s, args, kwargs))
NoReverseMatch: Reverse for 'session_view' with arguments '()' and
keyword arguments '{'year': 2012, 'slug':
u'mechanical-tools-morning-2', 'day': 14, 'month': 9}' not found.
How do I call reverse in the shell? Import it and...?
reverse(s)?
cheers
L.
--
...we look at the present day through a rear-view mirror. This is
something Marshall McLuhan said back in the Sixties, when the world
was in the grip of authentic-seeming future narratives. He said, "We
look at the present through a rear-view mirror. We march backwards
into the future."
http://www.warrenellis.com/?p=14314
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home