Forums

Static files not updating with python manage.py collectstatic

I'm attempting to update some javascript files within my projects static files. I'm noticing that they are not updating accordingly on PythonAnywhere. The changes were pushed to Github. Next I would pull the changes from Github to the console running on PythonAnywhere and run python manage.py collectstatic. Yet the older static files remain when I check the developer tools in my browsers console. It's seems the files have been cached?

I read the following article on this topic but have had no luck resolving the issue

  • https://help.pythonanywhere.com/pages/DebuggingStaticFiles/

Following the steps in that article, I've posted the URL of a JS script that is suppose to be running (AND updated) as an example as a Django View is requested. To verify that changes were pulled, I checked the Files and they show the updated changes that I made.

The URL which you expect to be able to load the static file from https://binnybit.pythonanywhere.com/main_static/posts/js/votings.js

The path where this file is stored on disk, in your PythonAnywhere account

/home/binnybit/django_stackoverflow/posts/static/posts/js/votings.js

The relevant static files mapping from the web tab, the values for its URL and path settings

Dashbord - Web tab

  • URL -> /main_static/
  • Directory -> /home/binnybit/django_stackoverflow/main_static

settings.py

STATIC_ROOT = os.path.join(BASE_DIR, "main_static")
STATIC_URL = '/main_static/'

Can we take a look at your files? We can see them from our admin interface, but we always ask for permission first.

Also, what specific difference would you expect to see between the files at https://binnybit.pythonanywhere.com/main_static/posts/js/votings.js and /home/binnybit/django_stackoverflow/posts/static/posts/js/votings.js?

You have my permission to look at the files.

To address your second question...it would simply be the URLs for the API calls that are directed towards my DRF Views. That was just one example with that particular script. There are multiple scripts that contain API calls within the authors and posts apps.

binnybit.pythonanywhere.com/main_static/posts/js/votings.js

  • The domain is set to localhost

/home/binnybit/django_stackoverflow/posts/static/posts/js/votings.js

  • The domain is dynamically set with window.location.origin

The reason domain was set to localhost originally was because the project was developed on my computer and cloned it onto PythonAnywhere.

When I go to https://binnybit.pythonanywhere.com/main_static/posts/js/votings.js, I see code that dynamically calculates the domain from window.location.origin. Could you try accessing that URL and then reloading the page while holding down the shift key? I'm wondering if your browser is caching an old version for some reason.