Opened 6 years ago
Closed 6 years ago
#30003 closed Cleanup/optimization (fixed)
Manage.py entry point
Reported by: | James Pic | Owned by: | nobody |
---|---|---|---|
Component: | Core (Management commands) | Version: | 2.1 |
Severity: | Normal | Keywords: | |
Cc: | James Pic | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Currently, manage.py-tpl executes in an
if __name__ == '__main__':
block.
While this might work when declaring manage.py as script in setup.py, a popular convention is to use the console_scripts entry_point in setup.py to define commands.
For manage.py-tpl to support console_scripts entry_point we only need to move the code from the if block into a new function ie. main(), then call main() it in the if-block.
Then, manage.py-tlp will also work as console_scripts entry_point with yourproject.manage:main, and using manage.py as script will also still work.
This removes a manual effort every time a project defines a console_scripts entry_point for the management CLI, without having to set DJANGO_SETTINGS_MODULE.
Change History (6)
comment:1 by , 6 years ago
Cc: | added |
---|---|
Description: | modified (diff) |
Has patch: | set |
Type: | Uncategorized → New feature |
comment:2 by , 6 years ago
Description: | modified (diff) |
---|
comment:3 by , 6 years ago
Type: | New feature → Cleanup/optimization |
---|
comment:4 by , 6 years ago
Triage Stage: | Unreviewed → Accepted |
---|
I'm going to Accept this pending any objections in review.
comment:5 by , 6 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Hi James,
You basically mean you want to reference
yourproject.manage:main
in your ownsetup.py
— is that correct?I would say, "just use a custom project template" but the patch itself is small/unobjectionable. (My own feeling is towards meh/
wontfix
but ...)