Fix breakage in django 1.6

sid happens to be None in one or more cases, just test it's not None before returning it.
Merge pull request #25 from artscoop/master

Fix transaction breakage in Django 1.6