Opened 9 years ago

Closed 9 years ago

#26733 closed Bug (duplicate)

ContentType.get_object_for_this_type fetches models from wrong database

Reported by: Stefan Wehrmeyer Owned by: nobody
Component: contrib.contenttypes Version: 1.9
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

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.

Change History (2)

comment:1 by Stefan Wehrmeyer, 9 years ago

comment:2 by Tim Graham, 9 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #16281

Note: See TracTickets for help on using tickets.
Back to Top