Blog / Python

Using Highcharts with Django 1.6 and Bootstrap 3

December 13, 2013

I was looking for a library to create charts to use for my Django app about a week ago and a friend suggested to try Highcharts as he had heard good things about it from fellow Python/Django developers.

Highcharts is a charting library purely written in JavaScript. The charts look really pretty and interactive. Using the library is quite easy, too, thanks to the well written documentation with lots of examples. You can view a …

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() # …

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 …

Loading initial data for your Django app using fixtures and South

November 13, 2013

I’ve been thinking about deployment for my app these last few days and one of the things I needed to be able to do is automatically load initial data to one of the tables. If you’re already using South (which you should be unless you have a very, very simple project), you can easily include this in a data migration by loading in a fixture.

You can accomplish this in a few simple steps:

1. …

Django 1.5 with Twitter Bootstrap 3

November 5, 2013

I finally decided to redo an old Django project of mine, GlucoseTracker, a web application for tracking blood sugar levels mainly for people with diabetes (I’ve been Type 1 diabetic since I was 13), using the latest version of Django and Twitter Bootstrap. I originally started this project to teach myself Django but I lost interest at some point and pretty much abandoned it.

That was over 2 years ago. Now, with more …