18 February 2013

If you perform a quick Google search for grabbing Gravatar profile photos for your users in Django, you may find a handful of snippets of code showing you how to build a template tag for doing so. This is great, because Gravatar is meant to be dynamic, and you want to be able to write that directly into your template so that you always have the latest Gravatar photo. However, there can be times where you simply want to "attach" a user's Gravatar photo to the user model itself, and have that information remain as part of the user model (which "feels" right to me, since having a dynamic Gravatar photo exist only in the template essentially means my user model doesn't "know" about its own photo, and that kind of irks me).