20
The problem here is that css/iconic/open-iconic-bootstrap.css
is referencing a file, open-iconic.eot
, which doesn’t exist in the expected location.
When you run collectstatic
with that storage backend Django attempts to rewrite all the URLs in your CSS files so they reference the files by their new names e.g, css/iconic/open-iconic.8a7442ca6bed.eot
. If it can’t find the file it stops with that error.
21
I just had this same issue and fixed it by removing this line from my settings file,
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
I got this line from the Heroku documentation page…
- [Django]-How to group by AND aggregate with Django
- [Django]-"gettext()" vs "gettext_lazy()" in Django
- [Django]-How to add multiple arguments to my custom template filter in a django template?
12
I’ve had this error claiming a missing .css file when all my .css files existed, because I trusted Heroku documentation:
STATIC_ROOT = 'staticfiles'
over WhiteNoise documentation:
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
The fix is trivial, but until Heroku fix their docs (I submitted feedback), lets make sure the solution at least appears in SO.
- [Django]-Single Table Inheritance in Django
- [Django]-Django create userprofile if does not exist
- [Django]-Writing test cases for django models
7
In newer versions of whitenoise there are only two storage classes available:
whitenoise.storage.CompressedManifestStaticFilesStorage
whitenoise.storage.CompressedStaticFilesStorage
This error will arise with CompressedManifestStaticFilesStorage
, in cases where any of your static assets refer to other assets that cannot be found by the staticfiles finder. This is because the HashedFilesMixin
parses all the files to find references to other assets, so that it can pregenerate hashes for all of them to add to the manifest.
There are two ways to resolve this:
-
Switch to using
CompressedStaticFilesStorage
(noManifest
), so that file hashes are not pre-rendered. -
Identify all the missing files reported during collectstatic and either ensure that they are present in your collected directories, or remove references to them in your static files.
- [Django]-Specifying a mySQL ENUM in a Django model
- [Django]-Django Rest Framework – APIView Pagination
- [Django]-Strings won't be translated in Django using format function available in Python 2.7
3
The issue here is that using
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
or
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage
uses Django’s static file storage in a different way than runserver does. See the Django docs for some explanation: https://docs.djangoproject.com/en/1.11/ref/contrib/staticfiles/#django.contrib.staticfiles.storage.ManifestStaticFilesStorage.manifest_strict
I believe the referenced manifest gets built when you run collectstatic, so doing so should fix this problem temporarily, but you likely don’t want to run collectstatic before every test run if you have modified any static files. Another solution would be to disable this setting for your tests, and just run it in production.
- [Django]-How can I pass my context variables to a javascript file in Django?
- [Django]-Allowing RabbitMQ-Server Connections
- [Django]-Redirect to named url pattern directly from urls.py in django?
2
I had similar problem, but with a twist.
I deployed on pythonanywhere. If I turn debug True, app runs fine. But if a turn debug False, app crashes with a error that with one line being the summary
ValueError: Missing staticfiles manifest entry for 'favicons/favicon.ico'
I changed from STATIC_ROOT = 'staticfiles
to STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
Deleted staticfiles
directory, then rerun python manage.py collectstatic
.
Now app runs fine
- [Django]-Annotating a Sum results in None rather than zero
- [Django]-Want to disable signals in Django testing
- [Django]-What's the difference between CharField and TextField in Django?
2
In development Django’s runserver
automatically takes over static file handling.
In most cases this is fine, however this means that some of the improvements that WhiteNoise makes to static file handling won’t be available in development and it opens up the possibility for differences in behaviour between development and production environments. For this reason it’s a good idea to use WhiteNoise in development as well.
You can disable Django’s static file handling and allow WhiteNoise to take over simply by passing the --nostatic
option to the runserver command, but you need to remember to add this option every time you call runserver. An easier way is to edit your settings.py file and add whitenoise.runserver_nostatic
to the top of your INSTALLED_APPS
list:
INSTALLED_APPS = [
'whitenoise.runserver_nostatic',
'django.contrib.staticfiles',
# ...]
Source – http://whitenoise.evans.io/en/stable/django.html#using-whitenoise-in-development
- [Django]-Django allauth social login: automatically linking social site profiles using the registered email
- [Django]-In a django model custom save() method, how should you identify a new object?
- [Django]-How does pgBouncer help to speed up Django
1
For me the fix was simply adding a ‘static’ folder to the top directory (myapp/static did the trick). If you are setting the STATIC_URL but don’t have that directory already created, it will throw an error, even though you aren’t using that directory for your static files with whitenoise.
STATIC_URL = '/static/'
- [Django]-Performing a getattr() style lookup in a django template
- [Django]-Django load block for css
- [Django]-Disable session creation in Django
1
There are two options:
- To add the proper link which is in css
- By removing the link of file which is not present from css
- [Django]-Test that user was logged in successfully
- [Django]-How can I use Django OAuth Toolkit with Python Social Auth?
- [Django]-Django multiple and dynamic databases
0
It worked for me by commenting out the whitenoise in settings.py in production.
#STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
#WHITENOISE_ROOT = os.path.join(BASE_DIR, 'staticfiles')
- [Django]-Invalid block tag: 'static'
- [Django]-Can I have a Django form without Model
- [Django]-What's the cleanest, simplest-to-get running datepicker in Django?
0
I’ve been dealing with this issue all day. It turns out the problem was the staticfiles
directory was not checked in to git. I created a dummy file inside this directory, checked it in and everything was fine. This was mentioned somewhere in the Whitenoise documentation too, I believe.
- [Django]-Django – Get only date from datetime.strptime
- [Django]-Can I Make a foreignKey to same model in django?
- [Django]-How to insert a checkbox in a django form
0
Be sure to check all your settings related to static files, especially making sure the paths are pointing to the right locations. I personally had one of my STATICFILES_DIRS
pointing to a wrong path.
- [Django]-OrderingFilter has no attribute 'filter_queryset'
- [Django]-ReactJS with Django – real usage
- [Django]-How do you dynamically hide form fields in Django?
0
Much like everyone else, I had a unique fix to this problem… turns out I had a url()
in my styles.css
file with bad syntax.
Once I changed:
background-image: url( '../images/futura_front_blank_medium.jpg' );
to
background-image: url('../images/futura_front_blank_medium.jpg');
(notice the subtle difference — I removed the spaces on either side of the string)
then python manage.py collectstatic
worked fine and I didn’t get that error.
- [Django]-Django release 1.5: 'url' requires a non-empty first argument. The syntax changed in Django 1.5
- [Django]-Django models – how to filter number of ForeignKey objects
- [Django]-Make sure only one worker launches the apscheduler event in a pyramid web app running multiple workers
0
The whitenoise.django.GzipManifestStaticFilesStorage
alias has now been removed. Instead you should use the correct import path: whitenoise.storage.CompressedManifestStaticFilesStorage
.
As per the doc here.
- [Django]-What's the idiomatic Python equivalent to Django's 'regroup' template tag?
- [Django]-Troubleshooting Site Slowness on a Nginx + Gunicorn + Django Stack
- [Django]-Django values_list vs values
0
In my case there was another solution. In Heroku config I had a setting:
DISABLE_COLLECTSTATIC=0
which should let Heroku collect static automaticly by pushing to heroku master, but it didn`t!.
What I did was removing this setting on
Heroku > my_app > settings > config vars
and after that Heroku collected staticfiles automaticly and problem dissappeard.
- [Django]-Related Field got invalid lookup: icontains
- [Django]-How to delete old image when update ImageField?
- [Django]-How can I get access to a Django Model field verbose name dynamically?
0
I didn’t face this issue until building my project’s docker image on Linux. I usually build on macOS.
I believe there is a difference in case sensitivity by default between the most common filesystems used by these two OSes.
I solved this issue by renaming the files linked from my CSS to all lowercase.
Previously:
url('/static/Some-File.png')
Now:
url('/static/some-file.png')
- [Django]-Django test app error – Got an error creating the test database: permission denied to create database
- [Django]-How do I create sub-applications in Django?
- [Django]-Django: Does prefetch_related() follow reverse relationship lookup?