Code

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#16599 closed Bug (wontfix)

Management commands are collected in the wrong order

Reported by: vanschelven 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 aaugustin 3 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 3 years ago by anonymous

  • Component changed from Uncategorized to Core (Management commands)
  • milestone set to 1.4
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to fixed
  • Status changed from new to closed
  • Type changed from Uncategorized to Bug

comment:4 Changed 3 years ago by aaugustin

  • milestone 1.4 deleted

Revert spam :(

Changed 3 years ago by aaugustin

comment:5 Changed 3 years ago by vanschelven

  • Resolution fixed deleted
  • Status changed from closed to reopened

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

comment:6 Changed 3 years ago by aaugustin

  • Triage Stage changed from Unreviewed to Design 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 Changed 3 years ago by anonymous

  • Resolution set to wontfix
  • Status changed from reopened to closed

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 Changed 3 years ago by jacob

Oops, that was me. Sorry.

Last edited 3 years ago by jacob (previous) (diff)

comment:9 Changed 3 years ago by russellm

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.