Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#12999 closed (fixed)

update_all_contenttypes in contenttypes.management fails in django 1.2

Reported by: lsbardel Owned by: nobody
Component: Contrib apps Version: master
Severity: Keywords: contenttypes
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: UI/UX:

Description

Bug introduced with multiple database support. The function loop over installed applications and call update_contenttypes without passing a keyworded "db" argument.
update_contenttypes fails when no "db" is available. To fix the problem I replaced

db = kwargs["db"]

with

db = kwargs.get('db',None)

Attachments (2)

management.diff (545 bytes) - added by lsbardel 5 years ago.
management_no_using.diff (1.5 KB) - added by lsbardel 5 years ago.

Download all attachments as: .zip

Change History (8)

Changed 5 years ago by lsbardel

comment:1 Changed 5 years ago by lsbardel

  • milestone 1.2 deleted
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 5 years ago by russellm

  • milestone set to 1.2
  • Patch needs improvement set
  • Triage Stage changed from Unreviewed to Accepted

To be clear, the issue is specifically with the update_all_contenttypes() call. This highlights that there are a couple of problems with the current implementation; there shouldn't be the need for calls to using in update_contenttypes().

Changed 5 years ago by lsbardel

comment:3 Changed 5 years ago by lsbardel

Removed "using" in update_contenttypes. This way ContentType objects will be saved in the default database or the one specified in the routing scheme.

comment:4 Changed 5 years ago by gabrielhurley

  • Component changed from Uncategorized to Contrib apps

comment:5 Changed 5 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

(In [12750]) Fixed #12999 -- Modified the contenttypes syncdb handler to use db router logic. Thanks to lsbardel for the report.

comment:6 Changed 4 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

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