django-staticfiles
django-staticfiles copied to clipboard
Added option into collectstatic command to ignore post-processing errors
Added option into collectstatic command to ignore errors raised on post-processing phase when files are missing. This way we can still continue to post-process the static files even when some files are missing. I've stumbled upon this issue when deploying last stable version of django-grappelli.
This option is also quite handy when using comment in CSS; because the cache storage doesn't care whether the url declaration in the CSS file is in a comment or not. So, a missing file from a commented declaration is legal from my side.
I'm seeing this, too. We've got some CSS that's got url()'s that refer to assets that are, say, served via an HttpRedirect in django-land and staticfiles barfs on them.
I guess one question is: should ignoring the errors be the default behavior? Personally, I think it makes sense to just ignore the url errors.
@philipn Honestly, i prefer errors raised by default, this way i'm informed in the first place an i know exactly what i'm doing when i'm ignoring them. Let's think this way : raising error - on missing files - is by default the good way. It follow the zen of python :
- Errors should never pass silently.
- Unless explicitly silenced. The second item is the purpose of the ignore flag. And last but not least : raising exception by default allow you to fix your CSS from missing files - because we always miss something up when refactoring, etc. And ignoring this error on the first place will generate 404 page on your production server, you will never notice it unless you look at your server log.
Totally agree with you about errors. This isn't necessarily an error, though. An exception is raised, but it's not always the case that there's anything wrong with the CSS or with the application. Sometimes the file may not be on the file system and that wasn't intended (as in your 404 example), but it could very well /not/ be producing a 404 -- it could just be served dynamically and not from the file system (this is what I was seeing).
But I think it's fine either way.
This looks like a good idea, but needs tests :)
EDIT: and docs!
OK, i'll add some tests and ping you back once done. Thanks for having review this patch.
EDIT: Arg, i'm so bad at docs :) Will be the occasion to tackle it.
@jezdez I've added tests and docs. Thanks in advance for your feedback.
I'm closing this pull request because it nos comes with a patch for #19. I'll try to make two different ones.
Opening back, since i'm struggling too much with github.
@jezdez bump !
Another bump, would be very helpful to support this.
another bump. I would really like to see this in core. Even better would be an option to log warnings instead of failing silently.
Another bump. suffering too much badly. would be very helpful. btw I am using Dj-1.6.1 from django.contrib.staticfiles
What is the exact option to make this work ?