Comments (6)
I've not used django-assets before but from a brief look at how it works I suspect that the problem is that it tries to generate the bundle files at runtime, the first time template is rendered, rather than generating everything beforehand.
WhiteNoise expects all static files to be in place at the time the application starts, so it won't pick up the files which are added afterwards.
It looks like django-assets has a ./manage.py assets build
command which can be used to generate the bundles upfront. If you use this then I think it should work. Generating assets at runtime is a bad pattern anyway, in my opinion.
Also, looking at those example URLs you've given, you're using django-assets versioning for your bundles which appends the version as query parameter, rather than making it part of the filename.
This will work with WhiteNoise, but you'll get better caching behaviour if you use Django's built-in versioning. The docs suggest that should work OK with django-assets:
http://django-assets.readthedocs.org/en/latest/staticfiles.html#cachedstaticfilestorage
from whitenoise.
I'm running with DEBUG=False so it does not try to generate files at runtime, the correct bundle files and whitenoise hashed files are generated with collectstatic.
Post-processed '/(MYPATH)/gen/packed.css' as '(MYPATH)/gen/packed.f76d4cf5e04f.css'
I'm using
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
so I guess the correct names of files should be used.
Any other insight?
from whitenoise.
Hmm... that looks right. Are you running this on Heroku? If so, when in the build process is ./manage.py assets build
getting run?
The basic rule is that anything that's in STATIC_ROOT
at the point the application starts will get served by WhiteNoise. So if a file is not getting served, it will be because for some reason it's not in the right place and the right time.
from whitenoise.
Running using gunicorn on my local machine.
Yes all is in the STATIC_ROOT because I ran collectstatic before.
I'm starting to think that the problem might me django-assets because when I run
curl -I 127.0.0.1:8000/static/gen/packed.5df0a1aaf07a.js whitenoise is serving the file.
from whitenoise.
@evansd What assets packing/minification solution do you use with whitenoise?
from whitenoise.
I'm using gulp. I just get gulp to write all it's files into a static_build
directory which is listed in my STATICFILES_DIRS
settting. Then contrib.staticfiles handles the versioning. Works well for me.
from whitenoise.
Related Issues (20)
- Python 3.11 support? HOT 2
- Should not handle POST, PUT or DELETE HTTP methods? HOT 2
- Can some files be excluded? HOT 1
- Static files not found / bad args passed to finders.find (dev, Windows) HOT 2
- Azure app service web application is throwing 500 internal server error when using whitenoise - CompressedManifestStaticFilesStorage and DEBUG = False HOT 5
- Clarify interaction between WHITENOISE_KEEP_ONLY_HASHED_FILES and WHITENOISE_ROOT HOT 2
- Clarification for using whitenoise with CDN on digital ocean HOT 2
- do not raise exception if sourceMappingURL rereferenced map is missing HOT 1
- Documentation pointer for nginx users HOT 3
- whitenoise.storage.MissingFileError HOT 1
- Upgrade to Django 4.2 raises new warning HOT 9
- `render` and `redirect` not working with Django, Gunicorn, and Whitenoise HOT 2
- Merge ASGIWhiteNoise HOT 3
- Django app on Azure: STORAGES (previously STATICFILES_STORAGE) WhiteNoise variable breaks application HOT 1
- Random PostgreSQL connection errors HOT 13
- whitenoise's scantree slows down test suite performance HOT 9
- STORAGES results in Server Error 500 HOT 6
- ValueError: Missing staticfiles manifest entry for 'css/animate.css' & results in Server Error 500
- [Question] Under what set of circumstances is WHITENOISE_MANIFEST_STRICT evaluated? HOT 5
- FileNotFoundError during scantree() caused by broken symlink
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from whitenoise.