'Django somehow accesses the static files even after i had deleted the whole static folder
I am new to Django, I had placed the static files in the project level static
folder and even in multiple applications inside the app/static/app
directory. Everything was working fine until I decided to delete few of the static files. The project is surprisingly accessing the deleted static files i.e images
and stylesheets
. I even had deleted both the static
and the staticfiles
folders and it still would access the static files that I had placed in these folders.
Following is a code snippet from my setting.py
file.
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
('accounts', os.path.join(BASE_DIR, 'accounts', 'static')),
('transport_resources', os.path.join(BASE_DIR, 'transport_resources', 'static')),]
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
Whatever I do with those static files, it still manages to access the old and even deleted files. I am assuming that it keeps a cache of the files that we had used previously if this is the case, how can we clear that cache. Thanks!
Solution 1:[1]
Renaming the new files to something other than the old file names did work.
Solution 2:[2]
I came across the same problem even after I deleted and run the $ python manage.py collectstatic --clear it still manages to access the file
this is because browser is caching static files
open it on another browser/incognito window
when I used another server problem solved
$ python manage.py runserver 9000
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Tomer Shetah |
Solution 2 |