(just butting in, because this came through to my inbox, but leaving the overall review to @rtibbles)

This is pretty standard, but another common approach is to wrap a regular `cls.objects.get(device=id)` in a `try` block, and then change the `if not cur_log` stuff into an `except cls.NotFound` block (or something like that).

Oh, but reading further, it looks like you might be able to take advantage of [`get_or_create`](https://docs.djangoproject.com/en/1.4/ref/models/querysets/#get-or-create).