changeset 666:ddc189ff96bb

For issue #46, mangle part of current time into avatar name to bust browser caches.
author Brian Neal <bgneal@gmail.com>
date Sat, 25 May 2013 00:22:40 -0500
parents 86d04190ff4e
children 264b08bce8b8
files bio/models.py
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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)