Added None-type checks for related objects in get_all_objects