[Django] #26733: ContentType.get_object_for_this_type fetches models from wrong database

22 views
Skip to first unread message

Django

unread,
Jun 9, 2016, 4:33:45 AM6/9/16
to django-...@googlegroups.com
#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.

Django

unread,
Jun 9, 2016, 4:52:14 AM6/9/16
to django-...@googlegroups.com
#26733: ContentType.get_object_for_this_type fetches models from wrong database
-------------------------------------+-------------------------------------

Reporter: stefanw | Owner: nobody
Type: Bug | Status: new
Component: | Version: 1.9
contrib.contenttypes |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by stefanw):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

Pull request here: https://github.com/django/django/pull/6748

--
Ticket URL: <https://code.djangoproject.com/ticket/26733#comment:1>

Django

unread,
Jun 9, 2016, 8:15:20 AM6/9/16
to django-...@googlegroups.com
#26733: ContentType.get_object_for_this_type fetches models from wrong database
-------------------------------------+-------------------------------------
Reporter: stefanw | Owner: nobody
Type: Bug | Status: closed
Component: | Version: 1.9
contrib.contenttypes |
Severity: Normal | Resolution: duplicate
Keywords: | Triage Stage:
| Unreviewed

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* status: new => closed
* resolution: => duplicate


Comment:

Duplicate of #16281

--
Ticket URL: <https://code.djangoproject.com/ticket/26733#comment:2>

Reply all
Reply to author
Forward
0 new messages