Admin "View on site" link broken

2 views
Skip to first unread message

Alan Green

unread,
Aug 27, 2006, 8:05:55 AM8/27/06
to django-d...@googlegroups.com
Hi,

I'm having a problem with the Admin "View on site" button. According
to http://www.djangoproject.com/documentation/model_api/#get-absolute-url
all I need to do is add a get_absolute_url() method to my model
objects and the admin interface will gain a "View on site" button that
links to my application's view of the object.

My model objects have a get_absolute_url() method, and the View on
site button appears as expected, however, the "View on site" button
links to strange relative urls like "../../../r/10003".

I dug around a little. The change_form.html template contains this code:

{% if has_absolute_url %}<li><a href="../../../r/{{ content_type_id
}}/{{ object_id }}/" class="viewsitelink">{% trans "View on site"
%}</a></li>{% endif%}

This looks like a bug with some history. What is going on here?

Alan.
--
Alan Green
al...@bright-green.com - http://bright-green.com

Michael van der Westhuizen

unread,
Aug 27, 2006, 8:22:08 AM8/27/06
to django-d...@googlegroups.com
Hi Alan,

On 8/27/06, Alan Green <alan....@gmail.com> wrote:
>
> Hi,
>
> I'm having a problem with the Admin "View on site" button. According

[snip]


> My model objects have a get_absolute_url() method, and the View on
> site button appears as expected, however, the "View on site" button
> links to strange relative urls like "../../../r/10003".

[snip]

While not a bug, this could certainly be documented better.

Just add the following to your root urlconf and things will work as expected:
( r'^r/', include( 'django.conf.urls.shortcut' ) ),

Hope that helps,
Michael

Reply all
Reply to author
Forward
0 new messages