Opened 2 years ago

Closed 2 years ago

#30003 closed Cleanup/optimization (fixed) 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 James Pic)

Currently, executes in an

if __name__ == '__main__':


While this might work when declaring as script in, a popular convention is to use the console_scripts entry_point in to define commands.

For 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, will also work as console_scripts entry_point with yourproject.manage:main, and using 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 Changed 2 years ago by James Pic

Cc: James Pic added
Description: modified (diff)
Has patch: set
Type: UncategorizedNew feature

comment:2 Changed 2 years ago by James Pic

Description: modified (diff)

comment:3 Changed 2 years ago by Carlton Gibson

Type: New featureCleanup/optimization

Hi James,

You basically mean you want to reference yourproject.manage:main in your own — 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 ...)

Last edited 2 years ago by Carlton Gibson (previous) (diff)

comment:4 Changed 2 years ago by Carlton Gibson

Triage Stage: UnreviewedAccepted

I'm going to Accept this pending any objections in review.

comment:5 Changed 2 years ago by Carlton Gibson

Triage Stage: AcceptedReady for checkin

comment:6 Changed 2 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: newclosed

In 9453bc7:

Fixed #30003 -- Added usable entry point in default

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