#26733: ContentType.get_object_for_this_type fetches models from wrong database
--------------------------------------+--------------------
Reporter: stefanw | Owner: nobody
Type: Bug | Status: new
Component: contrib.contenttypes | Version: 1.9
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Easy pickings: 1 | UI/UX: 0
--------------------------------------+--------------------
This is the code for `ContentType.get_object_for_this_type`:
{{{
self.model_class()._base_manager.using(self._state.db).get(**kwargs)
}}}
It forces the using of the contenttypes database for fetching the model
and that can fail when the model only appears in the non-default database
(where contenttypes ususally lives). Removing the `.using` clause fixes
this.
This bug manifests in the admin "View on site" button that uses the
contenttypes framework to redirect. A pull request is coming up.
--
Ticket URL: <https://code.djangoproject.com/ticket/26733>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/050.8c4ebce688f24355d77693503b7a391d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.