[Django] #30616: CommandTemplate Behavior Is Inconsistent

3 views
Skip to first unread message

Django

unread,
Jul 6, 2019, 6:03:13 AM7/6/19
to django-...@googlegroups.com
#30616: CommandTemplate Behavior Is Inconsistent
-------------------------------------+-------------------------------------
Reporter: John | Owner: nobody
Gooding |
Type: | Status: new
Uncategorized |
Component: Core | Version: 2.2
(Management commands) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Moving this here per Adam Johnson's request on the
[https://groups.google.com/d/msg/django-
developers/AfhN_mVYZrg/m0Wrt3WICQAJ developer forum].

To be clear, I am not saying there is a bug. It does what it is programmed
to do. I am saying the expected behavior of the API / CLI / whatever you
want to call it is inconsistent.

I am not going to get into an argument of what a "proper" django structure
is, etc. I want to focus purely on the behavior of the command.

A more "normal" setup might look like this:

{{{
/repository
manage.py
/project
settings.py
urls.py
etc..
/polls
models.py
etc...
}}}

When you run `python manage.py startapp polls` from the same directory as
manage.py, it will create the polls directory for you, normal expected
behavior.

Another, equally as valid setup looks like this:

{{{
repository/
manage.py
/project
settings.py
urls.py
etc...
/polls
models.py
etc...
/my_app_2
models.py
etc...
}}}

Where all of the apps live in the project directory, or perhaps some other
directory. Now if you try to execute `python manage.py startapp polls
project`, it will complain that the directory doesn't exist and that you
need to create it first. However if you `cd` into /project, and run
`python ../manage.py startapp polls`, it will create the directory for
you, even though it doesn't exist.

My ultimate point is this, the behavior of the command should not depend
on where it is ran. It should only care if the directory already exists or
not, which it does check, but the applied behavior of that check is
different depending on if you're in the
[https://github.com/django/django/blob/53209f78302a639032afabf5326d28d4ddd9d03c/django/core/management/templates.py#L68
line 68 if block] or the
[https://github.com/django/django/blob/53209f78302a639032afabf5326d28d4ddd9d03c/django/core/management/templates.py#L76
line 76 else block]. The applied behavior ought to be the same, regardless
of where the command is ran from.

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

Django

unread,
Jul 6, 2019, 6:23:06 AM7/6/19
to django-...@googlegroups.com
#30616: CommandTemplate Behavior Is Inconsistent.
-------------------------------------+-------------------------------------
Reporter: John Gooding | Owner: nobody
Type: Bug | Status: closed
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

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

* status: new => closed
* type: Uncategorized => Bug
* version: 2.2 => master
* resolution: => invalid


Comment:

Thanks for the report, however this behavior doesn't depend on where it is
run, it depends on arguments and this is a
[https://docs.djangoproject.com/en/2.2/ref/django-admin/#startapp
documented] behavior:

- `python ../manage.py startapp polls` - creates a Django app directory
structure in the current directory.
- `python manage.py startapp polls project` - creates a Django app
directory structure in the existing directory `project`, because you
provided an optional `destination`, see:

> "If the optional destination is provided, Django will use that existing
directory rather than creating a new one."

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

Django

unread,
Jul 6, 2019, 6:52:52 AM7/6/19
to django-...@googlegroups.com
#30616: CommandTemplate Behavior Is Inconsistent.
-------------------------------------+-------------------------------------
Reporter: John Gooding | Owner: nobody
Type: Bug | Status: closed
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

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

Comment (by John Gooding):

I never said it wasn't a documented behavior. I said the behavior isn't
consistent. I think saying it depends on arguments and not on where its
run, is completely pointless. They are one and the same, the argument is
the position. My point is the behavior can be improved, not that it is
broken, and I believe it warrants further discussion on that.

Replying to [comment:1 felixxm]:
> Thanks for the report, however this behavior doesn't depend on where it
is run, it depends on arguments and this is a


[https://docs.djangoproject.com/en/2.2/ref/django-admin/#startapp
documented] behavior:
>
> - `python ../manage.py startapp polls` - creates a Django app directory
structure in the current directory.
> - `python manage.py startapp polls project` - creates a Django app
directory structure in the existing directory `project`, because you
provided an optional `destination`, see:
>
> > "If the optional destination is provided, Django will use that
existing directory rather than creating a new one."

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

Reply all
Reply to author
Forward
0 new messages