Opened 4 years ago

Closed 8 months ago

#20189 closed New feature (fixed)

Collectstatic ignore list expansion on a per project basis

Reported by: Mark Jones Owned by: nobody
Component: contrib.staticfiles Version: master
Severity: Normal Keywords:
Cc: tomas.ehrlich@… 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

Currently collectstatic gets its default ignores from this code.

        ignore_patterns = options['ignore_patterns']
        if options['use_default_ignore_patterns']:
            ignore_patterns += ['CVS', '.*', '*~']

In some of my projects I need more than this, and the only way to get that behavior is to remember the command line options and patterns. Working on many different projects all the time, this is problematic for me.

I'd like to propose a settings file addition that would pull those ignore patterns from settings.COLLECT_STATIC_IGNORE or something similar.

I'd be willing to write the code if this is accepted. We could leave the default alone, but allow people to put various things in the list to make deployment less of a hassle.

Part of the issues for me include sass files, themes associated with sass files, "uncompiled" javascript that needs to be served on debug, but does not need to be in the production static folder.

Attachments (1)

ticket-20189.patch (3.6 KB) - added by Tomáš Ehrlich 3 years ago.
Added STATICFILES_IGNORE_PATTERNS to settings.

Download all attachments as: .zip

Change History (11)

comment:1 Changed 4 years ago by Tomas Krajca

Hi,

This is the file that the code is in https://github.com/django/django/blob/master/django/contrib/staticfiles/management/commands/collectstatic.py

This seems like a cool feature to me.

comment:2 Changed 4 years ago by Kamu

Triage Stage: UnreviewedAccepted

Changed 3 years ago by Tomáš Ehrlich

Attachment: ticket-20189.patch added

Added STATICFILES_IGNORE_PATTERNS to settings.

comment:3 Changed 3 years ago by Tomáš Ehrlich

Cc: tomas.ehrlich@… added
Has patch: set
Version: 1.5master

comment:4 Changed 3 years ago by Tomáš Ehrlich

I've added STATICFILES_IGNORE_PATTERNS setting. Implementation was mostly straightforward. The only problem is backward compatibility.

The default value of STATICFILES_IGNORE_PATTERNS is ['CVS', '.*', '*~'], the same as default patterns hard-coded in management command. When user passes --no-default-ignore option, these default patterns are substracted and deprecation warning raised.

Need review for this, also for docs. Tests passed.

comment:5 Changed 2 years ago by Tim Graham

Patch needs improvement: set

We try to avoid new settings at all costs, although I don't have any alternate suggestions in this case. Anyway, the patch needs to be updated.

comment:6 Changed 2 years ago by Tomáš Ehrlich

Patch needs improvement: unset

comment:7 Changed 2 years ago by Jannis Leidel

Patch needs improvement: set

This is simple, don't add a global setting but a parameter to the staticfiles app config. That's where such things belong now.

Last edited 2 years ago by Jannis Leidel (previous) (diff)

comment:8 Changed 8 months ago by Claude Paroz

Patch needs improvement: unset

Tried to provide a new PR with the app config way.

comment:9 Changed 8 months ago by Tim Graham

Triage Stage: AcceptedReady for checkin

comment:10 Changed 8 months ago by Claude Paroz <claude@…>

Resolution: fixed
Status: newclosed

In f4c2b8e:

Fixed #20189 -- Allowed customizing staticfiles ignored_patterns list

Thanks Tim Graham for the review.

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