Having an --include option for collectsstatic.

瀏覽次數:49 次
跳到第一則未讀訊息

Nick Sarbicki

未讀,
2018年1月9日 清晨7:53:342018/1/9
收件者: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.
回覆所有人
回覆作者
轉寄
0 則新訊息