Fix trouble with ForeignKey in NoneType