4

Is the any automated way to remove (or at least mark) unused non-used (non-referenced) files located in /static/ folder and its sub-folders in Django project?

0leg
  • 13,464
  • 16
  • 70
  • 94
  • 1
    Maybe you can see http://stackoverflow.com/questions/7050380/finding-unused-django-code-to-remove as this tools also marks static files. – Dunatotatos Feb 21 '16 at 09:13

1 Answers1

5

This is not neccessery since django will pick only the updated files, and the whole idea of collectstatic is that you don't have to manually manage the static files.

However, if the old files do take a lot of space, once in while you can delete all the files and directories in the static directory, and then run collectstatic again. Then the /static/ dir will include only the updated files.

Before you run this, check how much time does it take, and prepare for maintenance.

Note: Delete and re-create all files may still require reload of these files by the client browsers or a CDN. It depends on your specific configuration: CDN, caching headers that use the file creation dates, etc.

Aviah Laor
  • 3,620
  • 2
  • 22
  • 27