File: //lib/python3/dist-packages/django/db/models/fields/__pycache__/related.cpython-310.pyc
o
3�a2 � @ s� d dl Z d dlZd dl mZ d dlmZ d dlmZ d dlmZm Z d dl
mZmZ d dl
mZmZ d dlmZ d d lmZ d d
lmZ d dlmZmZmZ d dlmZ d d
lmZ d dlmZ d dl m!Z" ddl#m$Z$ ddl%m&Z& ddl'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z- ddl.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5 ddl6m7Z7m8Z8m9Z9m:Z: dZ;dd� Z<dd� Z=G dd� de&e$�Z>G dd� de>�Z?e?�@e2� e?�@e/� e?�@e4� e?�@e0� e?�@e1� e?�@e5� e?�@e3� G dd � d e?�ZAG d!d"� d"eA�ZBd#d$� ZCG d%d&� d&e>�ZDdS )'� N)�partial)�forms)�apps)�SettingsReference�settings)�checks�
exceptions)�
connection�router)�utils)�Q)�
LOOKUP_SEP)�CASCADE�SET_DEFAULT�SET_NULL)�PathInfo��make_model_tuple)�cached_property)�gettext_lazy� )�Field)�FieldCacheMixin)�ForeignKeyDeferredAttribute�ForwardManyToOneDescriptor�ForwardOneToOneDescriptor�ManyToManyDescriptor�ReverseManyToOneDescriptor�ReverseOneToOneDescriptor)�RelatedExact�RelatedGreaterThan�RelatedGreaterThanOrEqual� RelatedIn�
RelatedIsNull�RelatedLessThan�RelatedLessThanOrEqual)�ForeignObjectRel�
ManyToManyRel�ManyToOneRel�OneToOneRel�selfc C s2 |t kr| }t|t�rd|vrd| jj|f }|S )a�
Transform relation into a model or fully-qualified model string of the form
"app_label.ModelName", relative to scope_model.
The relation argument can be:
* RECURSIVE_RELATIONSHIP_CONSTANT, i.e. the string "self", in which case
the model argument will be returned.
* A bare model name without an app_label, in which case scope_model's
app_label will be prepended.
* An "app_label.ModelName" string.
* A model class, which will be returned unchanged.
�.�%s.%s)�RECURSIVE_RELATIONSHIP_CONSTANT�
isinstance�str�_meta� app_label)�scope_model�relation� r4 �A/usr/lib/python3/dist-packages/django/db/models/fields/related.py�resolve_relation% s
r6 c sL � g� fdd�|D � }dd� |D �}� j j}|jt| fi |��g|�R � S )a�
Schedule `function` to be called once `model` and all `related_models`
have been imported and registered with the app registry. `function` will
be called with the newly-loaded model classes as its positional arguments,
plus any optional keyword arguments.
The `model` argument must be a model class. Each subsequent positional
argument is another model, or a reference to another model - see
`resolve_relation()` for the various forms these may take. Any relative
references will be resolved relative to `model`.
This is a convenience wrapper for `Apps.lazy_model_operation` - the app
registry model used is the one found in `model._meta.apps`.
c s g | ]}t � |��qS r4 )r6 )�.0�rel��modelr4 r5 �
<listcomp>M s z*lazy_related_operation.<locals>.<listcomp>c s s � | ]}t |�V qd S �Nr )r7 �mr4 r4 r5 � <genexpr>N � � z)lazy_related_operation.<locals>.<genexpr>)r0 r �lazy_model_operationr )�functionr: �related_models�kwargs�models�
model_keysr r4 r9 r5 �lazy_related_operation>