Fixed #23862 -- Made sure m2m fields through to_field correcly work.

Can't this case be handled by calling related model's meta.get_field(link_field_name)? If that is the case, then the `for field in self.through._meta.fields` loop would be much simplified.