In development, the above tag would output "/static/css/example.css?0.234234" - the random number at the end cache busts so e.g. IE will always load the latest version of the file.
In production, the tag looks up the transformed filename in a dictionary, which looks something like this:
STATIC_ASSETS = {
"css/core.css": "css/core.b1b09227.min.css"
}
The deployment script includes a bit of code that goes through every file in the static directory, figures out the hash, renames it and then writes out that dictionary in a generated static_assets.py file ready to be deployed to the servers. There's a separate management script that pushes the renamed files to S3 - I run that before doing a deploy.The only really fiddly bit is that the script needs to rewrite all of the CSS files to include the updated filename of any referenced images. I'm using a dumb regex to do this:
css_url_re = re.compile(r'url\((["\']?)([^)]+?)\1\)')
Since we control the coding standards for our own CSS, there's no need to do anything more robust than that.