Search code examples
javascriptdjangostatic-files

How to change Django static files


I know this might be a really obvious question, but I'm doing a Django project where I have Javascript in my static files. However, I have noticed that whenever I make a change to those files, my web server doesn't reflect the changes. Is there some migration or something else I need to do to make my web server reflect changes to my static Javascript files? Thanks.


Solution

  • You might want to run python manage.py collectstatic on the webserver to put the static files in the correct folder. https://docs.djangoproject.com/en/3.1/howto/static-files/

    Another possible issue is caching. You could use ManifestStaticFilesStorage https://docs.djangoproject.com/en/3.1/ref/contrib/staticfiles/#manifeststaticfilesstorage to have new filenames whenever a file is updated and escape cache issues.