Opened 5 years ago
Closed 5 years ago
#32070 closed New feature (duplicate)
Add option to choose app when running management command
| Reported by: | Yuri Escalianti | Owned by: | nobody | 
|---|---|---|---|
| Component: | Core (Management commands) | Version: | 3.1 | 
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no | 
| Needs tests: | no | Patch needs improvement: | no | 
| Easy pickings: | no | UI/UX: | no | 
Description
In Django 3.1.2, if two apps have a management command with the same name, Django runs the one which belongs to the app that appears first in INSTALLED_APPS.
This is not an issue, unless the developer does not want to change the order of INSTALLED_APPS. In this case the developer has to workaround the conflict by:
- Overriding the management command and placing it inside another app with higher precedence in INSTALLED_APPS
or
- Changing other parts of the code that would be affected by changing the order of INSTALLED_APPS
To remove the need for those workarounds, I suggest adding an option to choose which app to use (therefore bypassing the INSTALLED_APPS order) when running the management command:
python manage.py --app myapp my_management_command
This would make Django run my_management_command from the app myapp.
Duplicate of #27189.