def get_related_model(field):
    """Gets the related model from a related field"""
    model = None
    if hasattr(field, 'related_model') and field.related_model:
        model = field.related_model
    elif hasattr(field, 'rel') and field.rel:
        model = field.rel.to
    return model
