← Back
Editing: related.cpython-311.pyc
� �|�e2 � � � 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;d� Z<d� Z= G d� de&e$� � Z> G d� de>� � Z?e?�@ e2� � e?�@ e/� � e?�@ e4� � e?�@ e0� � e?�@ e1� � e?�@ e5� � e?�@ e3� � G d� de?� � ZA G d� d eA� � ZBd!� ZC G 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 �t � |t k r| }t |t � � rd|vr| j j �d|��}|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. �.)�RECURSIVE_RELATIONSHIP_CONSTANT� isinstance�str�_meta� app_label)�scope_model�relations �A/usr/lib/python3/dist-packages/django/db/models/fields/related.py�resolve_relationr6 % sR � � �2�2�2��� �(�C� � � I��h���"-�"3�"=�"=�"=�x�x�H�H��O� c � �� �g�fd�|D � � z }d� |D � � }�j j } |j t | 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 �0 �� g | ]}t �|� � ��S � )r6 )�.0�rel�models �r5 � <listcomp>z*lazy_related_operation.<locals>.<listcomp>M s$ �� �O�O�O��(���4�4�O�O�Or7 c 3 �4 K � | ]}t |� � V � �d S �Nr )r; �ms r5 � <genexpr>z)lazy_related_operation.<locals>.<genexpr>N s+ � � � �6�6�!�"�1�%�%�6�6�6�6�6�6r7 )r1 r �lazy_model_operationr )�functionr= �related_models�kwargs�models� model_keysr s ` r5 �lazy_related_operationrI >