[Django] #32309: Allow including hidden directories for startproject/startapp --template

9 views
Skip to first unread message

Django

unread,
Jan 1, 2021, 9:58:59 AM1/1/21
to django-...@googlegroups.com
#32309: Allow including hidden directories for startproject/startapp --template
-------------------------------------+-------------------------------------
Reporter: sage | Owner: sage
Type: New | Status: assigned
feature |
Component: Core | Version: master
(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 |
-------------------------------------+-------------------------------------
The `startproject`/`startapp` `--template` command
[https://github.com/django/django/blob/master/django/core/management/templates.py#L129
ignores hidden directories]. This makes it impossible to render the files
in "hidden" directories of a project/app template, even if the file names
are explicitly specified using `--name`. One common use case is to render
a GitHub Actions configuration inside the `.github` directory, which is
"hidden" because it starts with a dot (`.`). A workaround is to move the
files out of the hidden directories (or rename the directories) and moving
them back after the template is rendered.

I've written some possible approaches in the
[https://groups.google.com/u/1/g/django-
developers/c/7ixiIzn7DDg/m/QckEjbFCAwAJ mailing list discussion].

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

Django

unread,
Jan 1, 2021, 10:04:46 AM1/1/21
to django-...@googlegroups.com
#32309: Allow including hidden directories for startproject/startapp --template
-------------------------------------+-------------------------------------
Reporter: sage | Owner: sage
Type: New feature | Status: assigned
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
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 sage):

[https://github.com/django/django/pull/13827 POC with a new --directory
option]. I chose this one because the implementation is pretty similar to
`--name`. Suggestions welcome.

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

Django

unread,
Jan 3, 2021, 11:39:09 AM1/3/21
to django-...@googlegroups.com
#32309: Allow including hidden directories for startproject/startapp --template
-------------------------------------+-------------------------------------
Reporter: sage | Owner: sage
Type: New feature | Status: assigned
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
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 Florian Apolloner):

Personally I find it counter-intuitive to add
`--extension/--file/--directory` to properly render a template. Imo it
would make more sense if templates could provide a `.json/.ini`
(whatever) file which would tell Django what to render…

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

Django

unread,
Jan 4, 2021, 3:31:28 AM1/4/21
to django-...@googlegroups.com
#32309: Allow including hidden directories for startproject/startapp --template
-------------------------------------+-------------------------------------
Reporter: sage | Owner: sage
Type: New feature | Status: assigned
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

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

* stage: Unreviewed => Accepted


Comment:

This was part of the original patch in
a9a0f0b03f9a02deb03617bf7e9773a307d1328f for #17042. That was a while ago.
Having `.` dirs/files perhaps wasn't so common then as now.

René on the list:

> I think I prefer explicit exclusion by the user (except for obvious
> cases like .git and __pycache__) because it's less surprising.

I think we could take that as a smaller (quicker?) way to address this
issue, allowing a follow-up if someone wants it with Florian's suggest to
add a config file to encode options.

--
Ticket URL: <https://code.djangoproject.com/ticket/32309#comment:3>

Django

unread,
Jan 13, 2021, 6:46:16 AM1/13/21
to django-...@googlegroups.com
#32309: Allow including hidden directories for startproject/startapp --template
-------------------------------------+-------------------------------------
Reporter: sage | Owner: sage
Type: New feature | Status: assigned
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

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

Comment (by sage):

> I think we could take that as a smaller (quicker?) way to address this
issue,
> allowing a follow-up if someone wants it with Florian's suggest
> to add a config file to encode options.

I've changed the PR to add an `--exclude` (`-x`) option instead, with
`.git` and `__pycache__` always excluded.

I can add docs and tests if the approach is good to go.

I know it's probably too late to hit the feature freeze for 3.2... but if
there's still time to push this in and I'm not around, feel free to pick
this up =)

--
Ticket URL: <https://code.djangoproject.com/ticket/32309#comment:4>

Django

unread,
May 28, 2021, 11:25:59 PM5/28/21
to django-...@googlegroups.com
#32309: Allow including hidden directories for startproject/startapp --template
-------------------------------------+-------------------------------------
Reporter: sage | Owner: sage
Type: New feature | Status: assigned
Component: Core (Management | Version: dev

commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* needs_docs: 0 => 1
* has_patch: 0 => 1
* needs_tests: 0 => 1


Comment:

Thanks for this, I think with positive reactions from Carlton and René
this is ready for a review once some docs and tests are included, so yes,
good to go.

[https://github.com/django/django/pull/13827 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/32309#comment:5>

Django

unread,
Jul 17, 2021, 11:24:10 PM7/17/21
to django-...@googlegroups.com
#32309: Allow including hidden directories for startproject/startapp --template
-------------------------------------+-------------------------------------
Reporter: sage | Owner: sage
Type: New feature | Status: assigned
Component: Core (Management | Version: dev
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

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

* needs_docs: 1 => 0
* needs_tests: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/32309#comment:6>

Django

unread,
Jul 18, 2021, 3:10:44 PM7/18/21
to django-...@googlegroups.com
#32309: Allow including hidden directories for startproject/startapp --template
-------------------------------------+-------------------------------------
Reporter: sage | Owner: sage
Type: New feature | Status: assigned
Component: Core (Management | Version: dev
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

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

Comment (by Chris Jerdonek):

Should including hidden directories be opt-in for backwards compatibility
reasons, since they're currently excluded? If the change automatically
includes them, it seems like there should be some kind of release note
letting users know. It seems like a safer change might be to keep the
current default the same.

--
Ticket URL: <https://code.djangoproject.com/ticket/32309#comment:7>

Django

unread,
Jul 19, 2021, 12:57:25 AM7/19/21
to django-...@googlegroups.com
#32309: Allow including hidden directories for startproject/startapp --template
-------------------------------------+-------------------------------------
Reporter: sage | Owner: sage
Type: New feature | Status: assigned
Component: Core (Management | Version: dev
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 0 => 1


Comment:

Replying to [comment:7 Chris Jerdonek]:


> Should including hidden directories be opt-in for backwards
compatibility reasons, since they're currently excluded? If the change
automatically includes them, it seems like there should be some kind of
release note letting users know. It seems like a safer change might be to
keep the current default the same.

Agreed. We could keep the current behavior if the `exclude` argument is
not passed.

--
Ticket URL: <https://code.djangoproject.com/ticket/32309#comment:8>

Django

unread,
Aug 3, 2021, 8:46:41 AM8/3/21
to django-...@googlegroups.com
#32309: Allow including hidden directories for startproject/startapp --template
-------------------------------------+-------------------------------------
Reporter: sage | Owner: sage
Type: New feature | Status: assigned
Component: Core (Management | Version: dev
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

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

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/32309#comment:9>

Django

unread,
Sep 1, 2021, 5:39:39 AM9/1/21
to django-...@googlegroups.com
#32309: Allow including hidden directories for startproject/startapp --template
-------------------------------------+-------------------------------------
Reporter: sage | Owner: sage
Type: New feature | Status: assigned
Component: Core (Management | Version: dev
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

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

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/32309#comment:10>

Django

unread,
Sep 1, 2021, 6:38:40 AM9/1/21
to django-...@googlegroups.com
#32309: Allow including hidden directories for startproject/startapp --template
-------------------------------------+-------------------------------------
Reporter: sage | Owner: sage
Type: New feature | Status: closed

Component: Core (Management | Version: dev
commands) |
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"84c7c4a477eae5de394d036d7ba1e58a37e18b69" 84c7c4a4]:
{{{
#!CommitTicketReference repository=""
revision="84c7c4a477eae5de394d036d7ba1e58a37e18b69"
Fixed #32309 -- Added --exclude option to startapp/startproject management
commands.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32309#comment:12>

Django

unread,
Sep 1, 2021, 6:38:40 AM9/1/21
to django-...@googlegroups.com
#32309: Allow including hidden directories for startproject/startapp --template
-------------------------------------+-------------------------------------
Reporter: sage | Owner: sage
Type: New feature | Status: assigned

Component: Core (Management | Version: dev
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

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

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"3686077d463685d383e14b4695eaaa2658919a42" 3686077d]:
{{{
#!CommitTicketReference repository=""
revision="3686077d463685d383e14b4695eaaa2658919a42"
Refs #32309 -- Added test for excluding hidden directories in startproject
command.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32309#comment:11>

Reply all
Reply to author
Forward
0 new messages