|
| 1 | +======================================== |
| 2 | +DEP XXXX: Name the main command `django` |
| 3 | +======================================== |
| 4 | + |
| 5 | +:DEP: XXXX |
| 6 | +:Author: Ryan Hiebert |
| 7 | +:Implementation Team: Ryan Hiebert |
| 8 | +:Shepherd: Tom Carrick |
| 9 | +:Status: Draft |
| 10 | +:Type: Feature |
| 11 | +:Created: 2025-01-07 |
| 12 | + |
| 13 | +.. contents:: Table of Contents |
| 14 | + :depth: 3 |
| 15 | + :local: |
| 16 | + |
| 17 | + |
| 18 | +Abstract |
| 19 | +======== |
| 20 | + |
| 21 | +Motivated by a desire to remove confusing papercuts in Django |
| 22 | +and to follow common convention in the Python ecosystem, |
| 23 | +this DEP proposes to add a new ``django`` command equivalent to |
| 24 | +the existing ``django-admin`` command, |
| 25 | +and to update the documentation to prefer this new spelling. |
| 26 | + |
| 27 | +Specification |
| 28 | +============= |
| 29 | + |
| 30 | +The ``django`` command will be added as the preferred spelling |
| 31 | +for the existing ``django-admin`` command. |
| 32 | + |
| 33 | +.. code-block:: diff |
| 34 | +
|
| 35 | + --- a/pyproject.toml |
| 36 | + +++ b/pyproject.toml |
| 37 | + @@ -45,2 +45,3 @@ |
| 38 | + [project.scripts] |
| 39 | + +django = "django.core.management:execute_from_command_line" |
| 40 | + django-admin = "django.core.management:execute_from_command_line" |
| 41 | +
|
| 42 | +Official documentation will be updated |
| 43 | +to reference this new ``django`` command |
| 44 | +everywhere that ``django-admin`` is currently referenced |
| 45 | +by searching the repository for ``django-admin`` |
| 46 | +and auditing each instance to determine |
| 47 | +if it is a reference to the command and should be updated. |
| 48 | +The implementor will coordinate with the translation team |
| 49 | +to assist in making all necessary translation updates. |
| 50 | + |
| 51 | +Backwards Compatibility |
| 52 | +======================= |
| 53 | + |
| 54 | +The existing ``django-admin`` command will remain indefinitely |
| 55 | +as an alias of the ``django`` command. |
| 56 | +There are no plans to deprecate or remove the ``django-admin`` alias. |
| 57 | + |
| 58 | +Motivation |
| 59 | +========== |
| 60 | + |
| 61 | +Django is how many people first learn Python, |
| 62 | +so the choices that Django makes have an outsized impact |
| 63 | +on the intuition they have of how things work in Python. |
| 64 | +This makes it more important that Django |
| 65 | +follow Python's simple and clean style, |
| 66 | +and match the conventions of the broader ecosystem. |
| 67 | + |
| 68 | +Naming the main command ``django`` |
| 69 | +can reduce new developer confusion and make it easier to remember |
| 70 | +by following the most typical patterns in both the Python ecosystem |
| 71 | +and in the broader software development world. |
| 72 | +Some Python examples include ``pip``, ``pytest``, and ``black``, |
| 73 | +and some broader examples include ``ember``, ``rails``, and ``vite``. |
| 74 | + |
| 75 | +The broad acceptance of this pattern has been reinforced |
| 76 | +by tools like ``uv tool run`` (aka ``uvx``) and ``pipx``, |
| 77 | +where commands that are the same as the package name |
| 78 | +get special privileges and a simpler syntax. |
| 79 | +For example ``uvx pytest`` automatically downloads and runs |
| 80 | +the ``pytest`` command from the ``pytest`` package. |
| 81 | + |
| 82 | +This pattern has been further reinforced |
| 83 | +by the common pattern of recommending to use, for example, |
| 84 | +``python -m pip`` to ensure that |
| 85 | +you're using the version of the module |
| 86 | +that is associated with your intended Python interpreter. |
| 87 | +The correspondance between the command name and the package name |
| 88 | +allows for a more intuitive mapping to the alternative style. |
| 89 | + |
| 90 | +The ``django`` command is shorter, |
| 91 | +and while tab completion is a common way to avoid typing long commmands |
| 92 | +not all developers use it, |
| 93 | +especially new developers who are still learning |
| 94 | +how the command line works. |
| 95 | +Mentors in Django Girls workshops have observed that |
| 96 | +people have trouble remembering that they can use tab completion. |
| 97 | + |
| 98 | +Some commenters have described this alternative as |
| 99 | +intuitive, fun, aesthetic, and modern. |
| 100 | +These subjective benefits |
| 101 | +are not sufficient motivation to make the change alone, |
| 102 | +and are likely to be largely based on the intuitions built |
| 103 | +from the motivations above, |
| 104 | +but they reinforce values that we desire in the project. |
| 105 | + |
| 106 | +Drawbacks |
| 107 | +========= |
| 108 | + |
| 109 | +All changes have some drawbacks, this is no exception. |
| 110 | +It is important to consider them, |
| 111 | +and to make sure that they are mitigated |
| 112 | +or are outweighed by the benefits, |
| 113 | +compared with the implied work of |
| 114 | +reviewing and assuring the quality of the change, |
| 115 | +which will fall to the fellows and community reviewers. |
| 116 | + |
| 117 | +Broad community effects |
| 118 | +----------------------- |
| 119 | + |
| 120 | +There are many existing tutorials and blog posts |
| 121 | +that reference the existing ``django-admin`` commmand, |
| 122 | +and authors may reasonably think it wisest to update them. |
| 123 | +This is work that will be done by the community, |
| 124 | +so we should be cautious with adding this burden. |
| 125 | + |
| 126 | +Because the existing command will remain, |
| 127 | +the benefits of having the command follow common conventions |
| 128 | +and build the right mental model for new developers outweighs the cost. |
| 129 | + |
| 130 | +More than one way to do it |
| 131 | +-------------------------- |
| 132 | + |
| 133 | +Having multiple ways to spell the same thing can be confusing |
| 134 | +by making it difficult for users to know which is the correct way, |
| 135 | +and worry what differences there are between them. |
| 136 | +This concern is especially relevant because of the volume |
| 137 | +of external resources that reference the existing command name. |
| 138 | + |
| 139 | +This drawback is partially mitigated by clear documentation |
| 140 | +that the two commands are equivalent, |
| 141 | +and the benefits of following common convention again outweight the cost. |
| 142 | + |
| 143 | +Ambiguity |
| 144 | +--------- |
| 145 | + |
| 146 | +The ``django`` command can be seen as a terminology conflict |
| 147 | +with the name of the Python package or the name of the project itself. |
| 148 | +However, Django is an exception to what most tools with a CLI do, |
| 149 | +so the current situation is already confusing to new users. |
| 150 | +It is worth the trade of some confusion over this ambiguity |
| 151 | +for the clarity gained by consistency with other tools. |
| 152 | +Over time, usage of the current command will be less common, |
| 153 | +and the confusion will be less likely to surface. |
| 154 | + |
| 155 | +Alternatives |
| 156 | +============ |
| 157 | + |
| 158 | +Beside the status quo, some other possibilities compete with this proposal. |
| 159 | + |
| 160 | +Only add an alias |
| 161 | +----------------- |
| 162 | + |
| 163 | +This could be a less invasive change by only adding the new command name, |
| 164 | +and not modifying the documentation. |
| 165 | +This would avoid the vast majority of the work involved in this change. |
| 166 | +However, some common challenges are caused |
| 167 | +by the command name being different from the package name, |
| 168 | +and won't be resolved until the documentation is updated as well. |
| 169 | +For example, users have tried to run |
| 170 | +``python -m django-admin`` instead of ``python -m django``, |
| 171 | +to mirror the pattern followed by |
| 172 | +other notable Python packages with commands. |
| 173 | + |
| 174 | +.. code-block:: bash |
| 175 | +
|
| 176 | + python -m django-admin startproject myproject |
| 177 | +
|
| 178 | +``django-admin`` is not a valid Python module name, |
| 179 | +so this command cannot be run in this way. |
| 180 | + |
| 181 | +Reserve the name |
| 182 | +---------------- |
| 183 | + |
| 184 | +``django-admin`` is only commonly used directly to create new projects, |
| 185 | +with ``django-admin startproject``, |
| 186 | +so it is reasonable to wonder whether matching ``django-admin`` |
| 187 | +is the optimal behavior for this name. |
| 188 | + |
| 189 | +One other interesting candidate for the ``django`` command has been suggested, |
| 190 | +which is to use it as a replacement for the generated ``manage.py`` script. |
| 191 | +Because the ``manage.py`` script is effectively |
| 192 | +a wrapper around the same code as ``django-admin``, |
| 193 | +``manage.py`` is a strict superset of ``django-admin``. |
| 194 | +This means that the ``django`` command could be expanded |
| 195 | +to be a replacement for ``manage.py`` in the future. |
| 196 | + |
| 197 | +Reference Implementation |
| 198 | +======================== |
| 199 | + |
| 200 | +Two separate proof of concept implementations were written |
| 201 | +by `Jeff Triplett`_ and `Ryan Hiebert`_. |
| 202 | + |
| 203 | +.. _Jeff Triplett: https://github.com/jefftriplett/django-cli-no-admin |
| 204 | +.. _Ryan Hiebert: https://github.com/ryanhiebert/django-cmd |
| 205 | + |
| 206 | +Copyright |
| 207 | +========= |
| 208 | + |
| 209 | +This document has been placed in the public domain per the Creative Commons |
| 210 | +CC0 1.0 Universal license (http://creativecommons.org/publicdomain/zero/1.0/deed). |
| 211 | + |
| 212 | +(All DEPs must include this exact copyright statement.) |
0 commit comments