def get_field_instance(instance, field_name, using=None):
    """
        Fieldfile sometimes references the wrong instance, correct this.
        Used in the `fallback_pre_save` and to fix Django Bug #25547

        Can use the `using` kwarg to change the instance that the `FieldFile`
        will receive.
    """
    if using is None:
        using = instance
    field = getattr(instance, field_name, None)
    if field:
        field.instance = using
    return field
