Having an --include option for collectsstatic.

49 views
Skip to first unread message

Nick Sarbicki

unread,
Jan 9, 2018, 7:53:34 AM1/9/18
to Django developers (Contributions to Django itself)
I recently found I needed to create a command to include specific files for collectstatic and ignore everything else (images and fonts). The opposite of the current --ignore functionality.

I've tried to do this with the current --ignore option using glob syntax but haven't managed to "ignore all but these file types".

I'm making this functionality now for my project but wondering if it would be a welcome addition to django itself?

Looking through the collectstatic code it should be doable by adding another if statement at https://github.com/django/django/blob/master/django/contrib/staticfiles/utils.py#L26

if include_patterns and not matches_patterns(fn, include_patterns):
   
continue

And some upstream changes to include "include_patterns" as an option for the file finders list methods and the collectstatic command itself.

Setting include_patterns to a default of None should make the addition backwards compatible for any third party finders.

Is there any interest in doing this? I accept my current use case is fairly niche but it may be useful for others.

Nick.
Reply all
Reply to author
Forward
0 new messages