Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#16599 closed Bug (wontfix)

Management commands are collected in the wrong order

Reported by: Klaas van Schelven Owned by: nobody
Component: Core (Management commands) Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When multiple management commands of the same name exist, the ones found in apps higher in the INSTALLED_APPS should get precedence; right now, it's reversed.

This is completely analogous to the problem described (and fixed) in
https://code.djangoproject.com/ticket/14924
One could basically read that ticket and replace "translations" by "management commands".

In this case, the relevant update statement may be found below:
https://code.djangoproject.com/browser/django/trunk/django/core/management/__init__.py?rev=16222#L117

I'm awfully sorry, don't have the time now to submit a patch. My thoughts would be: either run through the apps in reversed direction, or don't work with an update statement, but rather only add values to the dict if they're not present yet.
The previous, analogous solution is indeed based on 'reversed' and may be found here:
https://code.djangoproject.com/changeset/15441#file2

Attachments (1)

image001.jpg (13 bytes ) - added by Aymeric Augustin 13 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 by anonymous, 13 years ago

Component: UncategorizedCore (Management commands)
milestone: 1.4
Resolution: fixed
Status: newclosed
Type: UncategorizedBug

comment:4 by Aymeric Augustin, 13 years ago

milestone: 1.4

Revert spam :(

by Aymeric Augustin, 13 years ago

Attachment: image001.jpg added

comment:5 by Klaas van Schelven, 13 years ago

Resolution: fixed
Status: closedreopened

Bewgh... the spam also marked this as "fixed"

comment:6 by Aymeric Augustin, 13 years ago

Triage Stage: UnreviewedDesign decision needed

I'm afraid reversing the order is backwards incompatible. It could cause a wrong command to be executed after an update of Django, with unexpected consequences (read : data loss).

However, it makes sense to have the same order for management commands, templates, translations, and anything else that can be overridden. Otherwise, for instance, it's impossible for an app to override a command and a template of a contrib app.

comment:7 by anonymous, 13 years ago

Resolution: wontfix
Status: reopenedclosed

Actually, we've never promised anything about the order of evens in INSTALLED_APPS - the documentation's careful to indicate that the order ought to be considered an implementation detail, not an API. Given that, I'm going to mark this wontfix.

However, there's a very real need here for a consistant, accurate, bulletproof way to override management commands. A new ticket regarding that would be most welcome (especially if it has good ideas!)

Thanks!

comment:8 by Jacob, 13 years ago

Oops, that was me. Sorry.

Last edited 13 years ago by Jacob (previous) (diff)

comment:9 by Russell Keith-Magee, 13 years ago

As a side note, the proposed behavior would actually break a bunch of really useful features, including the way that static media is served by the runserver.

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