Fixed #36022 -- Renamed django-admin to django.#21260
Conversation
ryanhiebert
left a comment
There was a problem hiding this comment.
I left a review to try to point out some things in the code that I think reviewers may want to pay particular attention to.
One thing that I've not addressed, but that was pointed out on the ticket, is translations. These changes came from a full audit of every place where django-admin was in the codebase, but I don't see anything related to translation in them.
| rolename="djcmd", | ||
| indextemplate="pair: %s; django command", | ||
| parse_node=parse_django_cmd_node, | ||
| ) |
There was a problem hiding this comment.
We could alternatively name this directive django and the role dj or something. This seemed a little clearer in intent for when we're reading the source, but I can go either way.
| if objtype == "django-cmd": | ||
| objects.setdefault(("django-admin", name), value) | ||
|
|
||
|
|
There was a problem hiding this comment.
We could alternatively replace all existing uses of the :djadmin: role with simple text references that say django-admin. That's what I did in an earlier iteration, but I figured out how to do this, and it leaves cross references functional.
| $ man _build/man/django-admin.1 # do a quick sanity check | ||
| $ cp _build/man/django-admin.1 man/django-admin.1 | ||
| $ man _build/man/django.1 # do a quick sanity check | ||
| $ cp _build/man/django.1 man/django.1 man/django-admin.1 |
There was a problem hiding this comment.
It's worth calling out this change that will be the responsibility of the releaser. These instructions use the generated man page for both the django command as well as the django-admin command.
| ================================== | ||
| ======================================== | ||
| The ``django`` command and ``manage.py`` | ||
| ======================================== |
There was a problem hiding this comment.
I renamed this page to django-cmd. This will be in the URL. We could consider also keeping this page the same as it was previously to avoid breaking version switching, or renaming it to django instead.
| bcrypt = ["bcrypt>=4.1.1"] | ||
|
|
||
| [project.scripts] | ||
| django = "django.core.management:execute_from_command_line" |
There was a problem hiding this comment.
The money line.
| "they are equivalent except for the printing of this message. " | ||
| "For more details on the naming change, see DEP 16.\n" | ||
| ) | ||
|
|
There was a problem hiding this comment.
It's worth considering where exactly this is happening. Every call to django-admin will have this message. Printing to stderr is less likely to cause unexpected breakage than stdout, but we know how it goes with Hyrum's Law.
This change implements DEP 16, to rename the django-admin command to django. Wherever we reference the django-admin command in the docs, update it to reference `django` or “The django command”. Renamed the `django-admin` directive to `django-cmd`, and the `django-admin-option` directive to `django-cmd-option`. If we’re comfortable with it, we can drop the `-cmd`, but it seemed better to identify the places to change first. Created a `djcmd` role to replace `djadmin`. The `djadmin` role remains for use in historical release notes, but pointing to the renamed docs file. The instructions for generating the man page prefer the `django` spelling, even for the `django-admin` man page. Wherever we reference the django-admin command in the docs, updated it to reference `django` or “The django command”. Added warning message to django-admin command, as specified in DEP 16.
codingjoe
left a comment
There was a problem hiding this comment.
Nice, I'd love to help you to get this into 6.1 but it's going to be a tight squeeze.
My main concern is the ambiguity of django and django command. Commands are an established concept in Django, like migrate, collectstatic and co.
I would encourage you to go for CLI (or similar), as django-admin serves as the command line interface, for all the commands mentioned above. IMHO, this provides a neat separation. So going forward, we will always know what we are talking about.
I think there is also a lot of similar community adoption, like GitHub CLI or AWS CLI. Just to name a few.
I left some concrete but maybe not complete examples.
| # Special-cases: We want 'django --version' and | ||
| # 'django --help' to work, for backwards compatibility. |
There was a problem hiding this comment.
You have a premature line break now, but I prefer the diff readability in an otherwise gigantic PR.
| @@ -1,5 +1,5 @@ | |||
| """ | |||
| Invokes django-admin when the django module is run as a script. | |||
| Invokes the django command when the django module is run as a script. | |||
There was a problem hiding this comment.
Hm… maybe it's best to refer to this as "CLI", not a command. As we already use the wording Command for the features of the CLI.
| Invokes the django command when the django module is run as a script. | |
| Invokes the django CLI when the django module is run as a script. |
| app.add_object_type( | ||
| directivename="django-cmd", | ||
| rolename="djcmd", | ||
| indextemplate="pair: %s; django command", |
There was a problem hiding this comment.
| indextemplate="pair: %s; django command", | |
| indextemplate="pair: %s; django CLI", |
| node["ids"] = old_ids | ||
|
|
||
|
|
||
| def parse_django_cmd_node(env, sig, signode): |
There was a problem hiding this comment.
| def parse_django_cmd_node(env, sig, signode): | |
| def parse_django_cli_node(env, sig, signode): |
| ) | ||
| app.add_object_type( | ||
| directivename="django-cmd", | ||
| rolename="djcmd", |
There was a problem hiding this comment.
I am not a big fan of abbreviations. I ALWAYS have to look up the Sphinx's directives… But maybe that's just me.
| rolename="djcmd", | |
| rolename="django-cli", |
There was a problem hiding this comment.
The filename may need updating too.
| def test_builtin_command(self): | ||
| """ | ||
| directory: django-admin builtin commands fail with an error when no | ||
| directory: django builtin commands fail with an error when no |
There was a problem hiding this comment.
The django in each docstring is redundant IMHO:
| directory: django builtin commands fail with an error when no | |
| directory: builtin commands fail with an error when no |
|
|
||
| class MainModule(AdminScriptTestCase): | ||
| """python -m django works like django-admin.""" | ||
| """python -m django works like django.""" |
There was a problem hiding this comment.
Maybe ambigous.
| """python -m django works like django.""" | |
| """python -m django works like django CLI.""" |
| bcrypt = ["bcrypt>=4.1.1"] | ||
|
|
||
| [project.scripts] | ||
| django = "django.core.management:execute_from_command_line" |
Trac ticket number
ticket-36022
Branch description
This change implements DEP 16, to rename the django-admin command to django.
Wherever we reference the django-admin command in the docs, update it to reference
djangoor “The django command”.Renamed the
django-admindirective todjango-cmd, and thedjango-admin-optiondirective todjango-cmd-option. If we’re comfortable with it, we can drop the-cmd, but it seemed better to identify the places to change first.Created a
djcmdrole to replacedjadmin. Thedjadminrole remains for use in historical release notes, but pointing to the renamed docs file.The instructions for generating the man page prefer the
djangospelling, even for thedjango-adminman page.Wherever we reference the django-admin command in the docs, updated it to reference
djangoor “The django command”.Added warning message to django-admin command, as specified in DEP 16.
AI Assistance Disclosure (REQUIRED)
I used Copilot in vscode to help validate this work, and to help get me past my own mental blocks to finish the work.
I wrote the initial version entirely by hand many months ago, with the assistance of the standard find tool in vscode. Of course, I missed somethings and needed to test locally, so I spun up a devcontainer, and enabled Copilot to help me debug, evaluate my approach, and run the tests. It did suggest some changes, which I thoroughly reviewed and evaluated.
Checklist
mainbranch.