Opened 7 years ago

Closed 7 years ago

#28524 closed Cleanup/optimization (fixed)

Improve program name for Django's command-line utility.

Reported by: Nick Pope Owned by: Nick Pope
Component: Core (Management commands) Version: dev
Severity: Normal Keywords: command-line
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

By default, according to the documentation there are three ways to execute Django's command-line utility:

$ django-admin <command> [options]
$ manage.py <command> [options]
$ python -m django <command> [options]

When executing the help command, however, the way these are rendered may be incorrect:

$ django-admin help

Type 'django-admin help <subcommand>' for help on a specific subcommand.
...
$ ./manage.py help

Type 'manage.py help <subcommand>' for help on a specific subcommand.
...
$ python -m django help

Type '__main__.py help <subcommand>' for help on a specific subcommand.
...

It should also be noted that manage.py will typically not work and ./manage.py is required:

$ manage.py help
bash: manage.py: command not found

On Windows it will work, but only if the file type is associated with the Python interpreter and not an editor.

So, the issues here are:

  1. __main__.py should be replaced by python -m django (or possibly use os.path.basename(sys.executable))
  2. Should manage.py be replaced with ./manage.py on non-Windows platforms? What about Windows?
  3. What should happen with the manage.py option in the documentation?

Change History (6)

comment:1 by Nick Pope, 7 years ago

Has patch: set

comment:2 by Simon Charette, 7 years ago

Triage Stage: UnreviewedAccepted

Might want to ref #24857 in the commit message.

comment:3 by Simon Charette, 7 years ago

Needs tests: set

PR missing tests.

comment:4 by Nick Pope, 7 years ago

Needs tests: unset

Thanks Simon. Test added similar to existing one for manage.py; original commit referenced.

There probably ought to be a test for the program name in the help output for django-admin also, but the test suite executes it from the file path directly resulting in django-admin.py rather than the documented django-admin... Not really sure how to get around that.

What are your thoughts with respect to the other points in this ticket about manage.py?

comment:5 by Simon Charette, 7 years ago

What are your thoughts with respect to the other points in this ticket about manage.py?

About 2. I think it should stay the way it is because while it's invoked as ./manage.py most of the time I've seen python manage.py being used as well.

comment:6 by Tim Graham <timograham@…>, 7 years ago

Resolution: fixed
Status: assignedclosed

In ec648124:

Fixed #28524 -- Fixed program name in management commands when using 'python -m django'.

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