Opened 4 years ago

Closed 3 years ago

#32309 closed New feature (fixed)

Allow including hidden directories for startproject/startapp --template

Reported by: Sage Abdullah Owned by: Sage Abdullah
Component: Core (Management commands) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The startproject/startapp --template command 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 mailing list discussion.

Change History (12)

comment:1 by Sage Abdullah, 4 years ago

POC with a new --directory option. I chose this one because the implementation is pretty similar to --name. Suggestions welcome.

comment:2 by Florian Apolloner, 4 years ago

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…

comment:3 by Carlton Gibson, 4 years ago

Triage Stage: UnreviewedAccepted

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.

comment:4 by Sage Abdullah, 4 years ago

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 =)

comment:5 by Jacob Walls, 3 years ago

Has patch: set
Needs documentation: set
Needs tests: set

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.

PR

comment:6 by Sage Abdullah, 3 years ago

Needs documentation: unset
Needs tests: unset

comment:7 by Chris Jerdonek, 3 years ago

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.

in reply to:  7 comment:8 by Mariusz Felisiak, 3 years ago

Patch needs improvement: set

Replying to 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.

comment:9 by Sage Abdullah, 3 years ago

Patch needs improvement: unset

comment:10 by Mariusz Felisiak, 3 years ago

Triage Stage: AcceptedReady for checkin

comment:11 by Mariusz Felisiak <felisiak.mariusz@…>, 3 years ago

In 3686077d:

Refs #32309 -- Added test for excluding hidden directories in startproject command.

comment:12 by Mariusz Felisiak <felisiak.mariusz@…>, 3 years ago

Resolution: fixed
Status: assignedclosed

In 84c7c4a4:

Fixed #32309 -- Added --exclude option to startapp/startproject management commands.

Note: See TracTickets for help on using tickets.
Back to Top