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).
18 February 2013
27 August 2012
Posted By:Joey Espinosa | At:Monday, August 27, 2012
Be the first to comment!
In many cases when developing a Django application, you will be querying a database and displaying the results on a webpage (otherwise, why would you be using Django?). I'm going to go over a quick and easy way to display a certain amount of those results in sets within a Django template (2-to-a-row, 3-to-a-row, etc).
12 November 2011
Posted By:Joey Espinosa | At:Saturday, November 12, 2011
Be the first to comment!
I recently ran into a situation helping someone figure out how to execute a Python script and display the contents within a Django template. While his initial thought was to embed the entire script as Python code in an HTML template, a more elegant solution would be to simply run the script server-side and display the results using AJAX.
29 October 2011
Posted By:Joey Espinosa | At:Saturday, October 29, 2011
Be the first to comment!
I'm currently working on a website for a music company, which includes a full blown web application that will be accessible to members and assist in music distribution.
In order to make this happen, I have to be able to organize the tracks by genre. But keep in mind, this is a music company... they won't have anything but a huge library of music, so doing it manually is simply out of the question. Here's the other problem: Not all mp3s have ID3 tags (the tags that cause track details to appear on your player's display), and those that do may or may not fit in perfectly with your pre-defined items.
I wrote this in Python, so I wanted to share how I worked around this problem with calculating string similarity, rather than attempting to match strings or perform complex regular expressions to produce a possibly mediocre result.
In order to make this happen, I have to be able to organize the tracks by genre. But keep in mind, this is a music company... they won't have anything but a huge library of music, so doing it manually is simply out of the question. Here's the other problem: Not all mp3s have ID3 tags (the tags that cause track details to appear on your player's display), and those that do may or may not fit in perfectly with your pre-defined items.
I wrote this in Python, so I wanted to share how I worked around this problem with calculating string similarity, rather than attempting to match strings or perform complex regular expressions to produce a possibly mediocre result.
Subscribe to:
Posts (Atom)