On Tue, Mar 15, 2011 at 5:28 PM, Tomas Cirip <tci...@gmail.com> wrote:

> I am trying to understand 'view on site' functionality. From what I
> read it is supposed to use model's get_absolute_url() to create 'view
> on site' link. However, when I look at Django-1.2.5/django/contrib/
> admin/templates/admin/change_form.html code:
>
>  <ul class="object-tools"><li><a href="history/"
> class="historylink">{% trans "History" %}</a></li>
>  {% if has_absolute_url %}<li><a href="../../../r/
> {{ content_type_id }}/{{ object_id }}/" class="viewsitelink">{% trans
> "View on site" %}</a></li>{% endif%}
>  </ul>
>
> It doesn't use it to create the link. What is '../../../r/
> {{ content_type_id }}/{{ object_id }}/' in the code above?
>

That's a URL created by the admin for view on site functionality. It's
hooked up to the contenttypes shortcut view, see:

http://code.djangoproject.com/browser/django/trunk/django/contrib/admin/sites.py#L234

The referenced shortcut view is here:

http://code.djangoproject.com/browser/django/tags/releases/1.2.5/django/contrib/contenttypes/views.py?rev=15639#L6

Why is it
> creating link using content type? Why doesn't it use get_absolute_url
> to fetch the URL?
>

Not entirely sure (this is not an area of the code I've ever looked at) but
I'd guess it's due to the malarkey in that shortcut view having to do with
figuring out what site the object may be on.

Karen
-- 
http://tracey.org/kmt/

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to