Thursday, September 13, 2012

Re: get_absolute_url is returning '' instead of url

On Fri, Sep 14, 2012 at 1:38 PM, Russell Keith-Magee
<russell@keith-magee.com> wrote:
> On Fri, Sep 14, 2012 at 9:07 AM, Lachlan Musicman <datakid@gmail.com> wrote:
>> Hi,
>>
>> I'm getting blank get_absolute_url problems that I just can't solve. I
>> can get to an object by actually visiting the url that would be
>> constructed - I've checked that: app/session/year/month/day/slug
> …
>> And the view seems to be properly constructed - I've got debug on, and
>> I'm getting the page I expected rendering. It's only the
>> get_absolute_url that's coming back blank.
>
> 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 - I appreciate your quick and learned response. Unfortunately I'm
not as deep as you are and am still struggling with how the shell
actually works thoroughly, despite a number of attempts.

First: I'm not using reverse explicitly - I did leave a lot of non
useful code out of my post. Should I be importing the url reverse
function somewhere?

Second: if it's happening under the hood, which I expect is the case,
is there an easy way from within the shell to use the data I have
without having to import everything? Previous attempts have stalled at
"hey where is everything? Isn't settings/db/models imported? etc" Am
searching for django shell examples/howtos and revisiting the tutorial
in other tabs. Unfort am on very limited bandwidth connection (in
Kiribati, via satellite, semi regular brown/black outs).

My own thoughts have converged on "I presume if I wrote tests like
every normal dev then this would be a lot easier. Must learn tests.
Sometime soon."

> Next step; put some debug into get_absolute_url itself -- make a
> manual call to reverse inside get_absolute_url, and catch/print any
> exception that is raised.

Directly into the Django code? Ok. I can do that. I'm glad the
weekends coming and that I have the django and py docs in offline
html.

> Hopefully, that should give you enough detail as to the source of the problem.

Really appreciate your help.

L.


>
> Russ %-)
>
> --
> 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.
>



--
...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


Real Estate