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.