[Django] #28524: Improve program name for Django's command-line utility.

36 views
Skip to first unread message

Django

unread,
Aug 23, 2017, 8:55:11 AM8/23/17
to django-...@googlegroups.com
#28524: Improve program name for Django's command-line utility.
-------------------------------------+-------------------------------------
Reporter: Nick Pope | Owner: Nick Pope
Type: | Status: assigned
Cleanup/optimization |
Component: Core | Version: master
(Management commands) |
Severity: Normal | Keywords: command-line
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
By default, according to the [[https://docs.djangoproject.com/en/dev/ref
/django-admin/#usage|documentation]] there are three ways to execute
Django's command-line utility:

{{{#!sh
$ 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:

{{{#!console
$ django-admin help

Type 'django-admin help <subcommand>' for help on a specific subcommand.
...
}}}

{{{#!console
$ ./manage.py help

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

{{{#!console
$ 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:

{{{#!console
$ 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?

--
Ticket URL: <https://code.djangoproject.com/ticket/28524>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 23, 2017, 9:01:53 AM8/23/17
to django-...@googlegroups.com
#28524: Improve program name for Django's command-line utility.
-------------------------------------+-------------------------------------
Reporter: Nick Pope | Owner: Nick Pope
Type: | Status: assigned
Cleanup/optimization |
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
Keywords: command-line | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Nick Pope):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/28524#comment:1>

Django

unread,
Aug 24, 2017, 1:27:09 AM8/24/17
to django-...@googlegroups.com
#28524: Improve program name for Django's command-line utility.
-------------------------------------+-------------------------------------
Reporter: Nick Pope | Owner: Nick Pope
Type: | Status: assigned
Cleanup/optimization |
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
Keywords: command-line | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

* stage: Unreviewed => Accepted


Comment:

Might want to ref #24857 in the commit message.

--
Ticket URL: <https://code.djangoproject.com/ticket/28524#comment:2>

Django

unread,
Aug 24, 2017, 1:31:46 AM8/24/17
to django-...@googlegroups.com
#28524: Improve program name for Django's command-line utility.
-------------------------------------+-------------------------------------
Reporter: Nick Pope | Owner: Nick Pope
Type: | Status: assigned
Cleanup/optimization |
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
Keywords: command-line | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

* needs_tests: 0 => 1


Comment:

[https://github.com/django/django/pull/8961 PR] missing tests.

--
Ticket URL: <https://code.djangoproject.com/ticket/28524#comment:3>

Django

unread,
Aug 24, 2017, 5:10:32 AM8/24/17
to django-...@googlegroups.com
#28524: Improve program name for Django's command-line utility.
-------------------------------------+-------------------------------------
Reporter: Nick Pope | Owner: Nick Pope
Type: | Status: assigned
Cleanup/optimization |
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
Keywords: command-line | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Nick Pope):

* needs_tests: 1 => 0


Comment:

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`?

--
Ticket URL: <https://code.djangoproject.com/ticket/28524#comment:4>

Django

unread,
Aug 24, 2017, 10:12:50 AM8/24/17
to django-...@googlegroups.com
#28524: Improve program name for Django's command-line utility.
-------------------------------------+-------------------------------------
Reporter: Nick Pope | Owner: Nick Pope
Type: | Status: assigned
Cleanup/optimization |
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
Keywords: command-line | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Simon Charette):

> 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.

--
Ticket URL: <https://code.djangoproject.com/ticket/28524#comment:5>

Django

unread,
Aug 31, 2017, 9:22:45 AM8/31/17
to django-...@googlegroups.com
#28524: Improve program name for Django's command-line utility.
-------------------------------------+-------------------------------------
Reporter: Nick Pope | Owner: Nick Pope
Type: | Status: closed

Cleanup/optimization |
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution: fixed

Keywords: command-line | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"ec6481246a76f6a3339c987f14c3878f55cd7300" ec648124]:
{{{
#!CommitTicketReference repository=""
revision="ec6481246a76f6a3339c987f14c3878f55cd7300"
Fixed #28524 -- Fixed program name in management commands when using
'python -m django'.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28524#comment:6>

Reply all
Reply to author
Forward
0 new messages