0

Please point me to the right direction with a Django app that I am trying to put on Heroku. The app runs locally (both with python manage.py run server and heroku local), but doesn't run on heroku. It seems the root problem stems from whitenoise and I get errors doing collectstatic. BTW, whitenoise setup was done following the steps here for using whitenoise with Django. (app repo is here.)

Through various searches I found this that suggests setting the Node version on Heroku to use the same one used locally, but I am not using npm nor node. I tried the kill process tip from here, but that didn't help. Neither did heroku restart.

Doing python manage.py collectstatic --noinput got me these error messages:

Traceback (most recent call last):
  File "/Volumes/Volume2/dev/student_manage_csp/manage.py", line 22, in <module>
    main()
  File "/Volumes/Volume2/dev/student_manage_csp/manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/Volumes/Volume2/dev/student_manage_csp/venv/lib/python3.9/site-packages/django/core/management/__init__.py", line 425, in execute_from_command_line
    utility.execute()
  File "/Volumes/Volume2/dev/student_manage_csp/venv/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Volumes/Volume2/dev/student_manage_csp/venv/lib/python3.9/site-packages/django/core/management/base.py", line 373, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Volumes/Volume2/dev/student_manage_csp/venv/lib/python3.9/site-packages/django/core/management/base.py", line 417, in execute
    output = self.handle(*args, **options)
  File "/Volumes/Volume2/dev/student_manage_csp/venv/lib/python3.9/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 187, in handle
    collected = self.collect()
  File "/Volumes/Volume2/dev/student_manage_csp/venv/lib/python3.9/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 134, in collect
    raise processed
whitenoise.storage.MissingFileError: The file 'admin-lte/plugins/pdfmake/FileSaver.min.js.map' could not be found with <whitenoise.storage.CompressedManifestStaticFilesStorage object at 0x104531850>.

The JS file 'admin-lte/plugins/pdfmake/pdfmake.js' references a file which could not be found:
  admin-lte/plugins/pdfmake/FileSaver.min.js.map
YCode
  • 1,192
  • 1
  • 12
  • 28
  • See the answers on the question that I've marked this as a duplicate of - the issue is that one of more of your scripts are referencing files (in this case `FileSaver.min.js.map`) that can't be found by Django, and this raises an error. It's not specific to Whitenoise - it will happen with any manifest storage. You need to figure out why the files are missing, or remove references to them, or use a different storage engine. All these options are given in the linked answers. – solarissmoke Mar 31 '22 at 03:28
  • Thank you! The question/answers were from 5 years ago and `whitenoise` had updated their recommendations (eg `Gzip` is replaced is replaced with `compressed` in the `STATICFILES_STORAGE` line, among other things. Indeed, `whitenoise` may not be at fault, which is why I referenced the node/npm answer--the poster suggested that links to the 'missing files' were updated on the fly. I'd like to figure out how to get to the root of that. – YCode Mar 31 '22 at 03:49
  • 1
    The error is coming from the [`HashedFilesMixin`](https://github.com/django/django/blob/b811364421c8eea0cf06459462cf1fd58184773b/django/contrib/staticfiles/storage.py#L47), which parses all your static files and tries to resolve references to any other static assets they refer to. Any storage that uses this (i.e., anything that uses ManifestStorage) will have this issue. Gzip/compressed is not relevant. The only solutions are to (a) ensure the missing files are present or (b) stop using a storage that relies on a hash index of files. – solarissmoke Mar 31 '22 at 04:16
  • For learners. what storage do you suggest to use that doesn't rely on a hash index? – YCode Mar 31 '22 at 04:18
  • Use `whitenoise.storage.CompressedStaticFilesStorage` as opposed to `CompressedManifestStaticFilesStorage` - the first one doesn't use a manifest and doesn't generate file hashes. – solarissmoke Mar 31 '22 at 04:22
  • I've added [an answer](https://stackoverflow.com/a/71686908/3955830) to this effect on the old question. – solarissmoke Mar 31 '22 at 04:30

0 Answers0