def get_fk_query_name(model, related_model):
    """
    Format the DB column name of a foreign key field of a model
    with the DB table of the model. Finds the foreign key relating to 
    related model automatically, but assumes that there is only one related field.
    
    Args:
        model (Model): The model for which the foreign key field is searched.
        related_model (Model): A model related to `model`.
    
    Returns:
        str: The formated foreign key column name.
    """
    related_field = [f for f in model._meta.get_fields()
                     if f.is_relation and f.concrete and f.related_model == related_model]
    return '%s.%s' % (model._meta.db_table, related_field[0].column)