
    >Tf                         d dl mZ dZddZdS )    )ManyToOneRel)get_related_modelsTc                 Z    d | j         j        D             }|rt          |d           S |S )z
    Return a list of all models which have a ForeignKey to the given model and the name of the field. For example,
    `get_related_models(Tenant)` will return all models which have a ForeignKey relationship to Tenant.
    c                 `    g | ]+}t          |          t          u |j        |j        j        f,S  )typer   related_modelremote_fieldname).0fields     8/var/www/html/netbox-4.1.3/netbox/utilities/relations.py
<listcomp>z&get_related_models.<locals>.<listcomp>   sA       ;;,&& 
	e056&&&    c                 J    | d         j         j                                        S )Nr   )_metaverbose_namelower)xs    r   <lambda>z$get_related_models.<locals>.<lambda>   s    AaDJ4K4Q4Q4S4S r   )key)r   related_objectssorted)modelorderedrelated_modelss      r   r   r      sM    
 [0  N  Un*S*STTTTr   N)T)django.db.modelsr   __all__r   r   r   r   <module>r      s<    ) ) ) ) ) )
     r   