Setting up STATIC_URL dynamically for Subversion users

If you set STATIC_URL to a static value, then each time you update a CSS file, JavaScript file, or image, you will need to clear the browser cache in order to see the changes. There is a trick to work around clearing the browser's cache. It is to have the revision number of the version control system shown in STATIC_URL. Whenever the code is updated, the visitor's browser will force the loading of all-new static files.

This recipe shows how to put a revision number in STATIC_URL for subversion users.

Getting ready

Make sure that your project is under the subversion version control and you have BASE_DIR defined in your settings, as shown in the Defining relative paths in the settings recipe.

Get Django: Web Development with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.