Servering staticfiles issue

Settings.py:
MIDDLEWARE = [
‘django.middleware.security.SecurityMiddleware’,
‘whitenoise.middleware.WhiteNoiseMiddleware’,
‘django.contrib.sessions.middleware.SessionMiddleware’,
‘django.middleware.common.CommonMiddleware’,
‘django.middleware.csrf.CsrfViewMiddleware’,
‘django.contrib.auth.middleware.AuthenticationMiddleware’,
‘django.contrib.messages.middleware.MessageMiddleware’,
‘django.middleware.clickjacking.XFrameOptionsMiddleware’,
]
STATIC_URL = ‘/static/’
STATIC_ROOT = BASE_DIR / “staticfiles”
STATICFILES_STORAGE = “whitenoise.storage.CompressedManifestStaticFilesStorage”
STATICFILES_DIR = [
os.path.join(BASE_DIR, ‘static’),
os.path.join(BASE_DIR, ‘user_account/static’),
os.path.join(BASE_DIR, ‘videos_account/static’),
]
error logs:
Sep 11 01:32:14 PM Internal Server Error: /
Sep 11 01:32:14 PM Traceback (most recent call last):
Sep 11 01:32:14 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/django/core/handlers/exception.py”, line 47, in inner
Sep 11 01:32:14 PM response = get_response(request)
Sep 11 01:32:14 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/django/core/handlers/base.py”, line 181, in _get_response
Sep 11 01:32:14 PM response = wrapped_callback(request, *callback_args, **callback_kwargs)
Sep 11 01:32:14 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/django/utils/decorators.py”, line 130, in _wrapped_view
Sep 11 01:32:14 PM response = view_func(request, *args, **kwargs)
Sep 11 01:32:14 PM File “/opt/render/project/src/user_account/views.py”, line 91, in login_view
Sep 11 01:32:14 PM return render(request, ‘user_account/login.html’,context)
Sep 11 01:32:14 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/django/shortcuts.py”, line 19, in render
Sep 11 01:32:14 PM content = loader.render_to_string(template_name, context, request, using=using)
Sep 11 01:32:14 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/django/template/loader.py”, line 62, in render_to_string
Sep 11 01:32:14 PM return template.render(context, request)
Sep 11 01:32:14 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/django/template/backends/django.py”, line 61, in render
Sep 11 01:32:14 PM return self.template.render(context)
Sep 11 01:32:14 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/django/template/base.py”, line 170, in render
Sep 11 01:32:14 PM return self._render(context)
Sep 11 01:32:14 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/django/template/base.py”, line 162, in _render
Sep 11 01:32:14 PM return self.nodelist.render(context)
Sep 11 01:32:14 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/django/template/base.py”, line 938, in render
Sep 11 01:32:14 PM bit = node.render_annotated(context)
Sep 11 01:32:14 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/django/template/base.py”, line 905, in render_annotated
Sep 11 01:32:14 PM return self.render(context)
Sep 11 01:32:14 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/django/template/loader_tags.py”, line 150, in render
Sep 11 01:32:14 PM return compiled_parent._render(context)
Sep 11 01:32:14 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/django/template/base.py”, line 162, in _render
Sep 11 01:32:14 PM return self.nodelist.render(context)
Sep 11 01:32:14 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/django/template/base.py”, line 938, in render
Sep 11 01:32:14 PM bit = node.render_annotated(context)
Sep 11 01:32:14 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/django/template/base.py”, line 905, in render_annotated
Sep 11 01:32:14 PM return self.render(context)
Sep 11 01:32:14 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/django/templatetags/static.py”, line 106, in render
Sep 11 01:32:14 PM url = self.url(context)
Sep 11 01:32:14 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/django/templatetags/static.py”, line 103, in url
Sep 11 01:32:14 PM return self.handle_simple(path)
Sep 11 01:32:14 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/django/templatetags/static.py”, line 118, in handle_simple
Sep 11 01:32:14 PM return staticfiles_storage.url(path)
Sep 11 01:32:14 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/django/utils/functional.py”, line 246, in inner
Sep 11 01:32:14 PM self._setup()
Sep 11 01:32:14 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/django/contrib/staticfiles/storage.py”, line 438, in _setup
Sep 11 01:32:14 PM self._wrapped = get_storage_class(settings.STATICFILES_STORAGE)()
Sep 11 01:32:14 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/whitenoise/storage.py”, line 131, in init
Sep 11 01:32:14 PM super().init(*args, **kwargs)
Sep 11 01:32:14 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/django/contrib/staticfiles/storage.py”, line 373, in init
Sep 11 01:32:14 PM self.hashed_files = self.load_manifest()
Sep 11 01:32:14 PM File “/opt/render/project/src/.venv/lib/python3.7/site-packages/django/contrib/staticfiles/storage.py”, line 395, in load_manifest
Sep 11 01:32:14 PM (self.manifest_name, self.manifest_version))
Sep 11 01:32:14 PM ValueError: Couldn’t load manifest ‘staticfiles.json’ (version 1.0)
Sep 11 01:32:14 PM 127.0.0.1 - - [11/Sep/2023:10:32:14 +0000] “GET / HTTP/1.1” 500 158450 “-” “Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36”
Sep 11 01:33:54 PM ==> Detected service running on port 10000
Sep 11 01:33:54 PM ==> Docs on specifying a port: Web Services | Render · Cloud Hosting for Developers

Hi,

I’ve responded to this user privately, but for those who may be running into a similar problem, here’s a Stack Overflow post about this issue that might help:

The staticfiles.json manifest version changed in Django 4.2 (see commit).The error message Couldn't load manifest 'staticfiles.json' (version 1.0) is probably happening when Django before version 4.2 tries to parse a manifest made by Django 4.2, for example in the case of downgrading an instance of Django from version 4.2 to version 3.2.In this case, the easiest solution would be to empty out STATIC_ROOT and run collectstatic again.

Regards,
Mike


Render Support Engineer, MT (UTC-6)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.