#32734: django-admin startapp with trailing slash in directory name results in
error
--------------------------------------+------------------------
Reporter: jooadam | Owner: nobody
Type: Bug | Status: new
Component: Utilities | Version: 3.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
--------------------------------------+------------------------
Bash tab-completion appends trailing slashes to directory names. `django-
admin startapp name directory/` results in the error:
{{{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.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/050.8acbcf3ea2b96dad289fa8685fdba780%40djangoproject.com.