How can I properly implement ManifestStaticFilesStorage in Django?
I'm attempting to implement ManifestStaticFilesStorage in my Django project. From what I've seen, this should be simple, but it's not behaving in the way I expect.
Firstly, I have
DEBUG=os.getenv("DEBUG", "False").lower() == "true"
In my settings.py file, with DEBUG in my .env file set to "False".
Next, I have the following settings for my static files:
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'
MAX_DOCUMENT_FILE_SIZE_MB = 50
STATIC_URL = '/static/'
if LOCAL: # LOCAL is False here
STATIC_ROOT = os.path.join(BASE_DIR, 'static_collected')
else:
STATIC_ROOT = os.getenv('STATIC_ROOT')
Finally, for my own sanity, I have some print statements at the end of my settings file that output when I run collectstatic, which output:
STATICFILES_STORAGE: django.contrib.staticfiles.storage.ManifestStaticFilesStorage
STATIC_ROOT: /var/www/html/static
STATIC_URL: /static/
I have an nginx server set to serve static files at the above STATIC_ROOT. Finally, in my project's venv, I run
python manage.py collectstatic
And it copies the files successfully to the output directory I specified. The nginx server correctly serves them.
However, after all this, the filenames remain their basic iterations, rather than including a hash as I expect.
I'm using Django's {% static %} template in all my template HTML files.
I've tried deleting the entire static folder and re-running collectstatic, but it outputs the same thing each time.
I need the hash in the names, since these files change rather frequently in the beta stage that we're in, and instructing my users to hard refresh each time a JS file changes is not feasible.
I'm not sure what kind of configuration I may be missing here. Any assistance would be appreciated!