{{{CommandError: '' is not a valid app directory. Please make sure the
directory is a valid identifier.}}}
The error is caused by
[https://github.com/django/django/blob/main/django/core/management/templates.py#L77
line 77] of `django/core/management/templates.py` by calling `basename()`
on the path with no consideration for a trailing slash:
{{{#!python
self.validate_name(os.path.basename(target), 'directory')
}}}
Removing potential trailing slashes would solve the problem:
{{{#!python
self.validate_name(os.path.basename(target.rstrip(os.sep)), 'directory')
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32734>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* stage: Unreviewed => Accepted
Comment:
OK, yes, this seems a case we could handle.
I didn't look into exactly why but it works for `startproject`:
{{{
$ django-admin startproject ticket32734 testing/
}}}
Thanks for the report. Do you fancy making a PR?
--
Ticket URL: <https://code.djangoproject.com/ticket/32734#comment:1>
Comment (by Rohith P R):
> I didn't look into exactly why but it works for startproject
This is the relevant piece of code- should this same check be performed
for start project as well?
{{{
if app_or_project == 'app':
self.validate_name(os.path.basename(target), 'directory')
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32734#comment:2>
* owner: nobody => Rohith P R
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/32734#comment:3>
* owner: Rohith P R => jooadam
Comment:
Replying to [comment:3 Rohith P R]:
Rohith, sorry for not assigning it to me first, I just submitted a pull
request: https://github.com/django/django/pull/14383
--
Ticket URL: <https://code.djangoproject.com/ticket/32734#comment:4>
Comment (by Rohith P R):
Hey @jooadam! I already had a
[PR](https://github.com/django/django/pull/14382) open to fix this issue.
I left a comment on your PR btw. :)
--
Ticket URL: <https://code.djangoproject.com/ticket/32734#comment:5>
Comment (by jooadam):
Replying to [comment:5 Rohith P R]:
> Hey @jooadam! I already had a
[PR](https://github.com/django/django/pull/14382) open to fix this issue.
I left a comment on your PR btw. :)
Yeah, I saw it after the fact :/
--
Ticket URL: <https://code.djangoproject.com/ticket/32734#comment:6>
* owner: jooadam => Rohith P R
--
Ticket URL: <https://code.djangoproject.com/ticket/32734#comment:7>
* needs_better_patch: 0 => 1
Comment:
Regression in fc9566d42daf28cdaa25a5db1b5ade253ceb064f.
--
Ticket URL: <https://code.djangoproject.com/ticket/32734#comment:8>
* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/32734#comment:9>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"530f58caaa5052e9e56bf8461caee4d821953bcb" 530f58ca]:
{{{
#!CommitTicketReference repository=""
revision="530f58caaa5052e9e56bf8461caee4d821953bcb"
Fixed #32734 -- Fixed validation of startapp's directory with trailing
slash.
Regression in fc9566d42daf28cdaa25a5db1b5ade253ceb064f.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32734#comment:10>
Comment (by jooadam):
Replying to [comment:10 Mariusz Felisiak <felisiak.mariusz@…>]:
Mariusz, just wanted to say that I spent about four hours on my first
contribution to the project, that you just completely threw away here. I
probably won’t have a second.
--
Ticket URL: <https://code.djangoproject.com/ticket/32734#comment:11>
Comment (by Simon Charette):
jooadam, it's a shame that your contributing experience was not great and
to hear that your considering not repeating the experience but please be
fair to Mariusz here.
There was a miscommunication between multiple parties interested in
helping due to the lack of prior assignment of an owner and Mariusz has
little do to with that. I'm pretty sure Rohith also invested quite a lot
of time in getting his solution ready to address an an easy picking issue
and followed the contributing guidelines and in the end only a single
patch can land.
I sincerely hope you reconsider your decision that your realize these
hours were not completely thrown away as you've certainly learned a few
things about the contributing process along the way.
--
Ticket URL: <https://code.djangoproject.com/ticket/32734#comment:12>
Comment (by dotuser):
Does any plan backport https://github.com/django/django/pull/11270 and
https://github.com/django/django/pull/14382 to branch stable/2.2.x and
stable/3.2.x.
{{{
# https://github.com/django/django/pull/11270
(base) root@69faeb96:/tmp/123321/django# git branch -a --contains
fc9566d42daf28cdaa25a5db1b5ade253ceb064f
* main
stable/3.2.x
remotes/origin/HEAD -> origin/main
remotes/origin/main
remotes/origin/make-zoneinfo-default-timezone-implementation
remotes/origin/stable/3.0.x
remotes/origin/stable/3.1.x
remotes/origin/stable/3.2.x
# https://github.com/django/django/pull/14382
(base) root@69faeb96-0f43-442b-ad2d-3e5cfa31f6d5:/tmp/123321/django# git
branch -a --contains 530f58caaa5052e9e56bf8461caee4d821953bcb
* main
remotes/origin/HEAD -> origin/main
remotes/origin/main
remotes/origin/make-zoneinfo-default-timezone-implementation
}}}
Or, startapp will crash bug since PR
https://github.com/django/django/pull/11270:
{{{
(base) root@69faeb96:/tmp# /tmp/venv/bin/python -m django --version
3.2.6
(base) root@69faeb96:/tmp# /tmp/venv/bin/python -m django startproject
my_project -v3 && cd my_project
Rendering project template files with extensions: .py
Rendering project template files with filenames:
Creating /tmp/my_project/manage.py
Creating /tmp/my_project/my_project/__init__.py
Creating /tmp/my_project/my_project/asgi.py
Creating /tmp/my_project/my_project/settings.py
Creating /tmp/my_project/my_project/urls.py
Creating /tmp/my_project/my_project/wsgi.py
(base) root@69faeb96:/tmp/my_project# mkdir -p my_app && cd my_app
(base) root@69faeb96:/tmp/my_project/my_app# /tmp/venv/bin/python -m
django startapp my_app . -v3
CommandError: '.' is not a valid app directory. Please make sure the
directory is a valid identifier.
}}}
However, that's ok if startapp with other same method:
{{{
(base) root@69faeb96:/tmp/my_project/my_app# cd ..
(base) root@69faeb96:/tmp/my_project# ls
manage.py my_app my_project
(base) root@69faeb96:/tmp/my_project# rm -rf my_app/
(base) root@69faeb96:/tmp/my_project# ls
manage.py my_project
(base) root@69faeb96:/tmp/my_project# /tmp/venv/bin/python -m django
startapp my_app -v3
Rendering app template files with extensions: .py
Rendering app template files with filenames:
Creating /tmp/my_project/my_app/__init__.py
Creating /tmp/my_project/my_app/admin.py
Creating /tmp/my_project/my_app/apps.py
Creating /tmp/my_project/my_app/models.py
Creating /tmp/my_project/my_app/tests.py
Creating /tmp/my_project/my_app/views.py
Creating /tmp/my_project/my_app/migrations/__init__.py
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32734#comment:13>