Friday, April 29, 2011

Re: Multiple databases - unmanaged models - get_absolute_url()

OK, that's good.  However, I don't really understand why the admin site employs such an extremely convoluted method here.  If you follow the logic from the change form, here's what happens:

if has_absolute_url (i.e., the object model has a "get_absolute_url" attribute) ...
  -> display "view on site" link, which goes to ...
  -> view that looks up the content type object, then...
  -> gets the object of that type having the id passed in, then ...
  -> calls get_absolute_url() on the object, and ...
  -> redirects to that url

How is that ultimately different from:

if has_absolute_url 
  -> display "view on site" link with href="{{ obj.get_absolute_url }}"

(except that it appears the admin change form view doesn't pass the obj to the template context?!) ?

--David

On Friday, April 29, 2011 2:54:11 PM UTC-4, Ramiro Morales wrote:
On Fri, Apr 29, 2011 at 2:18 PM, David Chandek-Stark
<dchand...@gmail.com> wrote:

> [...]
>  Now, I think the problem
> is that this method uses the database for the contenttypes app instead of
> the alternate database
> (see http://code.djangoproject.com/browser/django/tags/releases/1.3/django/contrib/contenttypes/models.py#L102)
> because it explicitly calls using() with the model state of the ContentType
> object.
> Am I reading the Django code right, or am I doing something wrong?

Coincidentally, someone else has atached a patch for ticket [1]15610 today.

Any help with tests for the proposed fix is welcome.

--
Ramiro Morales

1. http://code.djangoproject.com/ticket/15610

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

No comments:

Post a Comment