                              # has a FK/O2O as the foreign key, use the FK value
                              if field.remote_field.model._meta.pk.remote_field:
                                  value = value.pk
                          else:
                              value = field.remote_field.model._meta.get_field(field.remote_field.field_name).to_python(field_value)
                          data[field.attname] = value
                      else:
                          data[field.attname] = field.remote_field.model._meta.get_field(field.remote_field.field_name).to_python(field_value)
                  else:
                      data[field.attname] = None
  
              # Handle all other fields
              else:
 
</s> remove                     if hasattr(field.remote_field.model._default_manager, 'get_by_natural_key'):
                        if hasattr(field_value, '__iter__') and not isinstance(field_value, six.text_type):
                            obj = field.remote_field.model._default_manager.db_manager(db).get_by_natural_key(*field_value)
                            value = getattr(obj, field.remote_field.field_name)
                            # If this is a natural foreign key to an object that
                            # has a FK/O2O as the foreign key, use the FK value
                            if field.remote_field.model._meta.pk.remote_field:
                                value = value.pk
 </s> add                     try:
                        if hasattr(field.remote_field.model._default_manager, 'get_by_natural_key'):
                            if hasattr(field_value, '__iter__') and not isinstance(field_value, six.text_type):
                                obj = field.remote_field.model._default_manager.db_manager(db).get_by_natural_key(*field_value)
                                value = getattr(obj, field.remote_field.field_name)
                                # If this is a natural foreign key to an object that
                                # has a FK/O2O as the foreign key, use the FK value
                                if field.remote_field.model._meta.pk.remote_field:
                                    value = value.pk
                            else:
                                value = field.remote_field.model._meta.get_field(field.remote_field.field_name).to_python(field_value)
                            data[field.attname] = value </s> remove                 data[field.name] = field.to_python(field_value)
 </s> add                 try:
                    data[field.name] = field.to_python(field_value)
                except Exception as e:
                    raise base.DeserializationError.WithData(e, d['model'], d.get('pk'), field_value) </s> remove                 m2m_data[field.name] = [m2m_convert(pk) for pk in field_value]
 </s> add                 try:
                    m2m_data[field.name] = []
                    for pk in field_value:
                        m2m_data[field.name].append(m2m_convert(pk))
                except Exception as e:
                    raise base.DeserializationError.WithData(e, d['model'], d.get('pk'), pk) </s> remove             data[Model._meta.pk.attname] = Model._meta.pk.to_python(d.get("pk", None))
 </s> add             try:
                data[Model._meta.pk.attname] = Model._meta.pk.to_python(d.get('pk'))
            except Exception as e:
                raise base.DeserializationError.WithData(e, d['model'], d.get('pk'), None)
                            data[field.attname] = field.remote_field.model._meta.get_field(field.remote_field.field_name).to_python(field_value)
                    except Exception as e:
                        raise base.DeserializationError.WithData(e, d['model'], d.get('pk'), field_value)
                              # has a FK/O2O as the foreign key, use the FK value
                              if field.remote_field.model._meta.pk.remote_field:
                                  value = value.pk
                          else:
                            data[field.attname] = field.remote_field.model._meta.get_field(field.remote_field.field_name).to_python(field_value)
                    except Exception as e:
                        raise base.DeserializationError.WithData(e, d['model'], d.get('pk'), field_value)
                            data[field.attname] = field.remote_field.model._meta.get_field(field.remote_field.field_name).to_python(field_value)
                    except Exception as e:
                        raise base.DeserializationError.WithData(e, d['model'], d.get('pk'), field_value)
                            data[field.attname] = field.remote_field.model._meta.get_field(field.remote_field.field_name).to_python(field_value)
                    except Exception as e:
                        raise base.DeserializationError.WithData(e, d['model'], d.get('pk'), field_value)
                            data[field.attname] = field.remote_field.model._meta.get_field(field.remote_field.field_name).to_python(field_value)
                    except Exception as e:
                        raise base.DeserializationError.WithData(e, d['model'], d.get('pk'), field_value)
                  else:
                      data[field.attname] = None
  
              # Handle all other fields
              else:
keep keep keep keep replace replace replace replace keep keep keep keep keep
 Fixed #19820 -- Added more helpful error messages to Python deserializer. 
django/core/serializers/python.py