Archive for the ‘Technology’ Category

django: Hacking django object_list to take list of templates

I recently found that you can pass a list or tuple to both django.template.loader.render_to_string and django.shortcuts.render_to_response. These functions iterate over the list of templates and render the first template that exists. The magic lies with the django.template.loader.get_template and select_template functions which take a single template name or list of templates respectively.
This is a great functionality [...]

SeenReport closes first round of funding

 
SeenReport (Pvt.) Ltd. has successfully closed its first round of investment from Al-Janabi Group (Official press release)
Phew, I had to keep this news secret for so long that I started having stomach problems. Now that its out, I feel much relieved . Yaser beat me to the blog post, here is his take on [...]

django: How to get model class from model name

How do you get the model class object from a string containing model name?
This came up multiple times during SeenReport development. While recording views, saving votes and adding comment on an object, I had to get the model class using the model name. The scenario would be,

The view receives the model name and object id
Fetch [...]

django: How to expire session on browser close

django employs cookies to track the user session. settings.SESSION_COOKIE_AGE defines the session expiration age in seconds. So, the user logs in once and can stay logged in for hours (even days).
But what if a user wants the session to expire as soon as the browser is closed? This is perfectly desirable for users on public/shared [...]

Cycorder, a free video app for iPhone

So you’ve got your hands on that sexy looking iPhone (2G/3G), you are feeling really proud of yourself, looking down on all those Nokia, Samsung, Sony Ericsson users.

Now you are showing it off to your friends, making them jealous by moving your fingers over the wide screen and enjoying the videos downloaded from youtube. When [...]

Running a MAC on Vostro 1510

This year when I decide to get a laptop, I initially wanted to buy a Mac Book. But I turned it down after looking at the price tag which to me was absurdly high. Instead decided to buy a Dell Vostro 1510 and then may be install Mac on it (just to say I am [...]

Twitter as a feedback/review service?

A couple of days ago, I was using (or trying to use) Wateen wimax internet at home and I couldnt get more than 2 KB/sec. To make matters worse, my server crashed and I had to download a 10KB file, change it and upload it back to server. With the blazing speed of Wateen @ [...]

django: generating absolute URLs

As I mentioned earlier, django provides a convenient and highly de-coupled way to manipulate URLs. At the heart of this functionality is django.core.urlresolver.reverse. This function however generates relative URLs e.g. /album/my-first-album/
At See’n’Report, we wanted every user to have a sub-domain so, hitting http://username.seenreport.com takes you to the user profile. But this created a small problem; all [...]

Twitter users in Pakistan:Tweet via SMS to a local number

Twitter is a well known name to almost every blogger. It provides a convenient and concise way to announce to the world what you are doing as well as get updates on what others are doing. Along with other modes, you can update your status by sending an SMS to Twitter. This way, you can broadcast [...]

django: playing with upload_to field

Django provides models.FileField & models.ImageField to save uploaded files & images respectively. Both these fields take a parameters ‘upload_to’ which defines the path where the uploaded file will be saved (complete path is settings.MEDIA_ROOT + upload_to). You can play some neat tricks with this little feature.
Creating the date based folders at run time
You can use the [...]