def get_related_model_fields(model, rel, is_foreign_key):
    """
    通过model下rel对象获取相关字段或关联属性
    """
    if (is_foreign_key and rel.field.model._meta.concrete_model == model.
        _meta.concrete_model):
        return rel.field, rel.get_related_field()
    return rel.get_related_field(), rel.field
