Opened 2 years ago

Last modified 13 months ago

#20189 new New feature

Collectstatic ignore list expansion on a per project basis

Reported by: mark0978 Owned by: nobody
Component: contrib.staticfiles Version: master
Severity: Normal Keywords:
Cc: tomas.ehrlich@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
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 Elvard 2 years ago.
Added STATICFILES_IGNORE_PATTERNS to settings.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 2 years ago by tomask

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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 2 years ago by Kamu

  • Triage Stage changed from Unreviewed to Accepted

Changed 2 years ago by Elvard

Added STATICFILES_IGNORE_PATTERNS to settings.

comment:3 Changed 2 years ago by Elvard

  • Cc tomas.ehrlich@… added
  • Has patch set
  • Version changed from 1.5 to master

comment:4 Changed 2 years ago by Elvard

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 13 months ago by timo

  • 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 13 months ago by Elvard

  • Patch needs improvement unset

comment:7 Changed 13 months ago by jezdez

  • 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 13 months ago by jezdez (previous) (diff)
Note: See TracTickets for help on using tickets.
Back to Top