# HG changeset patch # User Brian Neal # Date 1369459360 18000 # Node ID ddc189ff96bbd214de996bdac8e5e500f394e50d # Parent 86d04190ff4edab9fdae598eec9398d8ab6c0f16 For issue #46, mangle part of current time into avatar name to bust browser caches. diff -r 86d04190ff4e -r ddc189ff96bb bio/models.py --- a/bio/models.py Fri May 24 23:42:49 2013 -0500 +++ b/bio/models.py Sat May 25 00:22:40 2013 -0500 @@ -64,10 +64,14 @@ def avatar_file_path(instance, filename): + # The avatar's name is the username plus the current time plus the file + # extension. The time is used to bust browser caches. + # Get extension, if it exists: ext = os.path.splitext(filename)[1] if not ext: ext = '.jpg' - avatar_name = instance.user.username + ext + avatar_name = "{}{}{}".format(instance.user.username, + datetime.datetime.utcnow().strftime('%S%f'), ext) return os.path.join(settings.AVATAR_DIR, 'users', avatar_name)