Blog / Howto

Grouping data by field with the Django ORM

December 7, 2013

I just finished creating some charts for my Django app using Highcharts and had to group some data for them. I thought it would be just as simple as calling a group_by() method but turned out it works a little differently but still pretty straightforward and well documented.

Just to show an example (I’m using Django 1.6):

# glucoses/models.py

class Category(models.Model):
    name = models.CharField(unique=True, max_length=255)


class Glucose(TimeStampedModel):
    user = models.ForeignKey(User)
    value = models.PositiveIntegerField() # …

Auto-deploy your Django app to Heroku with Travis CI on git push

December 3, 2013

I was setting up a demo site for my latest open-source project, GlucoseTracker, a few weeks back and decided to run it on Heroku. The free tier (called ‘Hobby Dev’) allows 10,000 rows in a PostgreSQL database and 20 concurrent connections, which is more than good enough for me at this point.

I thought about using Jenkins CI to do the deployment to Heroku initially, but as I was installing it on my …

AT&T GoPhone: How to get the 10 cents/minute plan with your smartphone

November 29, 2013

I just recently came back to the US and had to get a new SIM card (which you can get on Amazon for about $0.25+shipping (should come out to less than $2), a lot cheaper than the $10 AT&T charges). I don’t want to subscribe to their plans that give you unlimited voice or text messaging as I rarely use my cellphone service. I really just want to have it in case of an emergency. …

Loading dummy data for your Django app using management commands

November 23, 2013

I’m at a point in my project now, GlucoseTracker, a web application for keeping tracking of blood sugar levels, where I’m starting to work on reporting and statistics. I need some dummy data automatically loaded in the database to work on this part and I need to refresh the data every few days or so.

It would be too much work to do this manually so I wrote a simple script that would be …

How to add additional pages to your US passport in Bangkok, Thailand

June 24, 2013

I finally reached the point where my passport had only one blank page left, thanks to all these visas taking up an entire page each.

I just got 48 additional pages added to my passport today at the US embassy here in Bangkok. The process took less than an hour, but cost me $82 USD. You can choose to have 1 insert (24 pages) or 2 (48 pages) added. Cost is the same. I …