403Webshell
Server IP : 217.160.0.135  /  Your IP : 216.73.217.85
Web Server : Apache
System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64
User : sws1074145052 ( 1074145052)
PHP Version : 8.3.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/django/db/models/fields/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/django/db/models/fields/__pycache__/related_descriptors.cpython-311.pyc
�

�|�e-����dZddlmZddlmZmZmZddlmZm	Z	ddl
mZddlm
Z
ddlmZddlmZGd	�d
e
��ZGd�d��ZGd
�de��ZGd�d��ZGd�d��Zd�ZGd�de��Zd�ZdS)a�

Accessors for related objects.

When a field defines a relation between two models, each model class provides
an attribute to access related instances of the other model class (unless the
reverse accessor has been disabled with related_name='+').

Accessors are implemented as descriptors in order to customize access and
assignment. This module defines the descriptor classes.

Forward accessors follow foreign keys. Reverse accessors trace them back. For
example, with the following models::

    class Parent(Model):
        pass

    class Child(Model):
        parent = ForeignKey(Parent, related_name='children')

 ``child.parent`` is a forward many-to-one relation. ``parent.children`` is a
reverse many-to-one relation.

There are three types of relations (many-to-one, one-to-one, and many-to-many)
and two directions (forward and reverse) for a total of six combinations.

1. Related instance on the forward side of a many-to-one relation:
   ``ForwardManyToOneDescriptor``.

   Uniqueness of foreign key values is irrelevant to accessing the related
   instance, making the many-to-one and one-to-one cases identical as far as
   the descriptor is concerned. The constraint is checked upstream (unicity
   validation in forms) or downstream (unique indexes in the database).

2. Related instance on the forward side of a one-to-one
   relation: ``ForwardOneToOneDescriptor``.

   It avoids querying the database when accessing the parent link field in
   a multi-table inheritance scenario.

3. Related instance on the reverse side of a one-to-one relation:
   ``ReverseOneToOneDescriptor``.

   One-to-one relations are asymmetrical, despite the apparent symmetry of the
   name, because they're implemented in the database with a foreign key from
   one table to another. As a consequence ``ReverseOneToOneDescriptor`` is
   slightly different from ``ForwardManyToOneDescriptor``.

4. Related objects manager for related instances on the reverse side of a
   many-to-one relation: ``ReverseManyToOneDescriptor``.

   Unlike the previous two classes, this one provides access to a collection
   of objects. It returns a manager rather than an instance.

5. Related objects manager for related instances on the forward or reverse
   sides of a many-to-many relation: ``ManyToManyDescriptor``.

   Many-to-many relations are symmetrical. The syntax of Django models
   requires declaring them on one side but that's an implementation detail.
   They could be declared on the other side without any change in behavior.
   Therefore the forward and reverse descriptors can be the same.

   If you're looking for ``ForwardManyToManyDescriptor`` or
   ``ReverseManyToManyDescriptor``, use ``ManyToManyDescriptor`` instead.
�)�
FieldError)�connections�router�transaction)�Q�signals)�QuerySet)�DeferredAttribute)�resolve_callables)�cached_propertyc��eZdZd�ZdS)�ForeignKeyDeferredAttributec���|j�|jj��|kr4|j�|��r|j�|��||j|jj<dS�N)�__dict__�get�field�attname�	is_cached�delete_cached_value��self�instance�values   �M/usr/lib/python3/dist-packages/django/db/models/fields/related_descriptors.py�__set__z#ForeignKeyDeferredAttribute.__set__Lsg���� � ���!3�4�4��=�=�$�*�BV�BV�W_�B`�B`�=��J�*�*�8�4�4�4�05���$�*�,�-�-�-�N)�__name__�
__module__�__qualname__r�rrrrKs#������6�6�6�6�6rrc�\�eZdZdZd�Zed���Zd�Zd�Zdd�Z	d�Z
dd	�Zd
�Zd�Z
dS)
�ForwardManyToOneDescriptoraJ
    Accessor to the related object on the forward side of a many-to-one or
    one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example::

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    ``Child.parent`` is a ``ForwardManyToOneDescriptor`` instance.
    c��||_dSr)r)r�field_with_rels  r�__init__z#ForwardManyToOneDescriptor.__init___s
��#��
�
�
rc	��td|jjjjt
f|jjj|jjj�d|jj�d�d���S�N�RelatedObjectDoesNotExist�.z.RelatedObjectDoesNotExist)rr )	�typer�remote_field�model�DoesNotExist�AttributeErrorrr �name�rs rr)z4ForwardManyToOneDescriptor.RelatedObjectDoesNotExistbsd��
�'�
�Z�
$�
*�
7��H�"�j�.�9��J�$�1�1�1��J�O�O�O�!�K�K�	
�	
�		
rc�6�|j�|��Sr)rr�rrs  rrz$ForwardManyToOneDescriptor.is_cachedrs���z�#�#�H�-�-�-rc�z�|jjjj�|������S�N)�hints)rr,r-�
_base_manager�
db_manager�all�rr6s  r�get_querysetz'ForwardManyToOneDescriptor.get_querysetus0���z�&�,�:�E�E�E�E�R�R�V�V�X�X�XrNc�~�
�|�|���}|�|d���|jj}|jj�
�
fd�|D��}|jjd}|jj}|���st|jj��dkrd|j	z�
fd�|D��i}nd|j�
��z|i}|jd	i|��}|js,|D])}|||��}	|�
||	���*||�
d|j���dfS)
Nr�rc�(��i|]}�|��|��Sr!r!��.0�inst�
instance_attrs  �r�
<dictcomp>zDForwardManyToOneDescriptor.get_prefetch_queryset.<locals>.<dictcomp>�%���J�J�J��-�-��-�-�t�J�J�Jr��%s__inc�2��h|]}�|��d��S)rr!r?s  �r�	<setcomp>zCForwardManyToOneDescriptor.get_prefetch_queryset.<locals>.<setcomp>�s)���4b�4b�4b�PT�]�]�4�5H�5H��5K�4b�4b�4brTFr!)r;�
_add_hintsr�get_foreign_related_value�get_local_related_value�foreign_related_fieldsr,�	is_hidden�lenr0�related_query_name�filter�multiple�set_cached_value�get_cache_name)r�	instances�queryset�rel_obj_attr�instances_dict�
related_fieldr,�query�rel_objrrBs          @r�get_prefetch_querysetz0ForwardManyToOneDescriptor.get_prefetch_querysetxsv������(�(�*�*�H����Y�q�\��2�2�2��z�;���
�:�
�J�J�J�J�	�J�J�J���
�9�!�<�
��z�.���!�!�#�#�	L�s�4�:�+L�'M�'M�QR�'R�'R��
� 2�2�4b�4b�4b�4b�Xa�4b�4b�4b�c�E�E���
� =� =� ?� ?�?��K�E�"�8�?�+�+�U�+�+���$�	A�#�
A�
A��)�,�,�w�*?�*?�@���-�-�g�x�@�@�@�@���}�d�D�J�<U�<U�<W�<W�Y^�^�^rc��|�|���}|�|j�|����S�Nr=)r;rr�get_reverse_related_filter)rr�qss   r�
get_objectz%ForwardManyToOneDescriptor.get_object�s:��
�
�
��
�
1�
1���v�v�d�j�;�;�H�E�E�F�F�Frc���|�|S	|j�|��}n�#t$r�d|j�|��v}|r$|j�|jj��nd}|rG|�|��r2|�|��}|j�|d���}nd}|�@|r>|�|��}|jj	}|j
s|�||��|j�||��YnwxYw|�@|jjs4|�
|jjj�d|jj�d����|S)a=
        Get the related instance through the forward relation.

        With the example above, when getting ``child.parent``:

        - ``self`` is the descriptor managing the ``parent`` attribute
        - ``instance`` is the ``child`` instance
        - ``cls`` is the ``Child`` class (we don't need it)
        N��default� has no r*)r�get_cached_value�KeyErrorrK�_meta�get_ancestor_linkr-rr`r,rQrR�nullr)rr0)rr�clsrZ�	has_value�
ancestor_link�ancestorr,s        r�__get__z"ForwardManyToOneDescriptor.__get__�s������K�
	;��j�1�1�(�;�;�G�G���	;�	;�	;��D�J�$F�$F�x�$P�$P�P�I�R[�e�H�N�<�<�T�Z�=M�N�N�N�ae�M��
��!8�!8��!B�!B�
�)�9�9�(�C�C���*�5�5�h��5�M�M�������9���/�/�(�3�3��#�z�6��$�,�E� �1�1�'�8�D�D�D��J�'�'��'�:�:�:�:�:�)	;����,�?�4�:�?�?��0�0�#'�:�#3�#<�#<�#<�d�j�o�o�o�N���
��Ns�!�C6D�Dc���|�rt||jjjjj��sIt
d|�d|jj�d|jj�d|jjjjj�d�	���|��|j	j
�%tj|j
|���|j	_
|j	j
�%tj|j
|���|j	_
tj||��st
d|z���|jj}|�]|j�|d�	��}|�|�|d��|jjD]\}}t%||jd���n;|jjD].\}}t%||jt)||j�����/|j�||��|�|js|�||��dSdSdS)
aX
        Set the related instance through the forward relation.

        With the example above, when setting ``child.parent = parent``:

        - ``self`` is the descriptor managing the ``parent`` attribute
        - ``instance`` is the ``child`` instance
        - ``value`` is the ``parent`` instance on the right of the equal sign
        N�Cannot assign "�": "r*�
" must be a "�" instance.r=�GCannot assign "%r": the current database router prevents this relation.rb)�
isinstancerr,r-rg�concrete_model�
ValueError�object_namer0�_state�dbr�db_for_write�	__class__�allow_relationrerR�related_fields�setattrr�getattrrQ)rrrr,�related�lh_field�rh_fields       rrz"ForwardManyToOneDescriptor.__set__�s����Z��t�z�7N�7T�7Z�7i�%j�%j���*��E�E��N�.�.�.��J�O�O�O��J�+�1�7�C�C�C�	���
��
���!�)�%+�%8��9K�V[�%\�%\�%\���"��|��&�"(�"5�e�o�PX�"Y�"Y�"Y�����(���9�9�
t� �!j�mr�!r�s�s�s��z�.��
�=��j�1�1�(�D�1�I�I�G�
�"��-�-�g�t�<�<�<�&*�j�&?�
:�
:�"��(���(�"2�D�9�9�9�9�
:�
'+�j�&?�
V�
V�"��(���(�"2�G�E�8�CS�4T�4T�U�U�U�U�	
�
�#�#�H�e�4�4�4�
��\�%:���)�)�%��:�:�:�:�:����rc�@�t|jj|jjffS)z�
        Pickling should return the instance attached by self.field on the
        model, not a new copy of that descriptor. Use getattr() to retrieve
        the instance directly from the model.
        )r�rr-r0r1s r�
__reduce__z%ForwardManyToOneDescriptor.__reduce__
s�����)�4�:�?�;�;�;rr)rrr �__doc__r&rr)rr;r[r`rnrr�r!rrr#r#Rs�������
�
�$�$�$��

�

��_�

�.�.�.�Y�Y�Y�_�_�_�_�>G�G�G�
-�-�-�-�^@;�@;�@;�D<�<�<�<�<rr#c�,��eZdZdZ�fd�Z�fd�Z�xZS)�ForwardOneToOneDescriptora
    Accessor to the related object on the forward side of a one-to-one relation.

    In the example::

        class Restaurant(Model):
            place = OneToOneField(Place, related_name='restaurant')

    ``Restaurant.place`` is a ``ForwardOneToOneDescriptor`` instance.
    c�����|jjjr�����}|jjj}d�|jjD���t�fd�|D����sD�fd��D��}|di|��}�jj	|j_	�jj
|j_
|St������S)Nc��g|]	}|j��
Sr!)r�r@rs  r�
<listcomp>z8ForwardOneToOneDescriptor.get_object.<locals>.<listcomp>(s��Q�Q�Q��e�m�Q�Q�Qrc3� �K�|]}|�vV��	dSrr!)r@r�fieldss  �r�	<genexpr>z7ForwardOneToOneDescriptor.get_object.<locals>.<genexpr>-s'�����=�=�5�u���=�=�=�=�=�=rc�2��i|]}|t�|����Sr!)r��r@rrs  �rrCz8ForwardOneToOneDescriptor.get_object.<locals>.<dictcomp>.s%���N�N�N�e�%���5�!9�!9�N�N�Nrr!)
rr,�parent_link�get_deferred_fieldsr-rg�concrete_fields�anyry�addingrz�superr`)rr�deferred�	rel_model�kwargs�objr�r|s `    @�rr`z$ForwardOneToOneDescriptor.get_object"s�������:�"�.�	��3�3�5�5�H��
�/�5�I�Q�Q���1P�Q�Q�Q�F�
�=�=�=�=�H�=�=�=�=�=�
�N�N�N�N�v�N�N�N���i�)�)�&�)�)��$,�O�$:��
�!� (�� 2��
�
��
��w�w�!�!�(�+�+�+rc�H��t���||��|jjrn|jjjr_|j}d�|jD��}|D]F}|jjjj	j
}|�t||��nd}t|||���CdSdSdS)Nc�.�g|]}|j�	|j�|��Sr!)�primary_keyr,r�s  rr�z5ForwardOneToOneDescriptor.__set__.<locals>.<listcomp><s<��#�#�#���$�#�).�);�#��#�#�#r)
r�rrr�r,r�rgr�r-�pkrr�r)	rrr�opts�inherited_pk_fieldsr�rel_model_pk_name�	raw_valuer|s	        �rrz!ForwardOneToOneDescriptor.__set__5s����
������%�(�(�(��:�!�
	@�d�j�&=�&I�
	@��>�D�#�#�#'�#7�#�#�#��-�
@�
@��$)�$6�$<�$B�$E�$M�!�AF�AR�G�E�+<�=�=�=�X\�	���"3�Y�?�?�?�?�
	@�
	@�
	@�
	@�
@�
@r)rrr r�r`r�
__classcell__�r|s@rr�r�sd�������	�	�,�,�,�,�,�&@�@�@�@�@�@�@�@�@rr�c�V�eZdZdZd�Zed���Zd�Zd�Zdd�Z	dd�Z
d	�Zd
�ZdS)�ReverseOneToOneDescriptora
    Accessor to the related object on the reverse side of a one-to-one
    relation.

    In the example::

        class Restaurant(Model):
            place = OneToOneField(Place, related_name='restaurant')

    ``Place.restaurant`` is a ``ReverseOneToOneDescriptor`` instance.
    c��||_dSr)r�)rr�s  rr&z"ReverseOneToOneDescriptor.__init__Ss������rc	��td|jjjtf|jjj|jjj�d|jj�d�d���Sr()	r+r��
related_modelr.r/r-rr r0r1s rr)z3ReverseOneToOneDescriptor.RelatedObjectDoesNotExistXsd���'�
�\�
'�
4�n�E�"�l�0�;��L�&�3�3�3��L�%�%�%�!�H�H�	
�	
�		
rc�6�|j�|��Sr)r�rr3s  rrz#ReverseOneToOneDescriptor.is_cachedgs���|�%�%�h�/�/�/rc�p�|jjj�|������Sr5)r�r�r7r8r9r:s  rr;z&ReverseOneToOneDescriptor.get_querysetjs-���|�)�7�B�B��B�O�O�S�S�U�U�UrNc���|�|���}|�|d���|jjj}|jjj��fd�|D��}d|jjjz|i}|jdi|��}|D]3}|||��}|jj�||���4||�d|j�	��dfS)Nrr=c�(��i|]}�|��|��Sr!r!r?s  �rrCzCReverseOneToOneDescriptor.get_prefetch_queryset.<locals>.<dictcomp>trDrrFTFr!)
r;rIr�rrKrJr0rPrRrS)	rrTrUrVrWrYrZrrBs	        @rr[z/ReverseOneToOneDescriptor.get_prefetch_querysetms�������(�(�*�*�H����Y�q�\��2�2�2��|�)�A����*�D�
�J�J�J�J�	�J�J�J���D�L�.�3�3�Y�?��"�8�?�+�+�U�+�+�� �	C�	C�G�%�l�l�7�&;�&;�<�H��L��/�/���B�B�B�B���}�d�D�L�<W�<W�<Y�<Y�[`�`�`rc�,�|�|S	|j�|��}n�#t$r�|j}|�d}n~|jj�|��}	|�|���jdi|��}|jj�||��n#|jj	j
$rd}YnwxYw|j�||��YnwxYw|�<|�|jj
�d|j����d����|S)a�
        Get the related instance through the reverse relation.

        With the example above, when getting ``place.restaurant``:

        - ``self`` is the descriptor managing the ``restaurant`` attribute
        - ``instance`` is the ``place`` instance
        - ``cls`` is the ``Place`` class (unused)

        Keep in mind that ``Restaurant`` holds the foreign key to ``Place``.
        Nr=rdr*r!)r�rerfr�r�get_forward_related_filterr;rrRr�r.r)r|r�get_accessor_name)rrrjrZ�
related_pk�filter_argss      rrnz!ReverseOneToOneDescriptor.__get__s`�����K�
	=��l�3�3�H�=�=�G�G���	=�	=�	=�!��J��!����"�l�0�K�K�H�U�U��K�F�d�/�/��/�B�B�F�U�U��U�U�G��L�&�7�7���J�J�J�J��
�|�1�>�#�#�#�"�G�G�G�#����
�L�)�)�(�G�<�<�<�<�<�	=����"�?��0�0��&�/�/�/��L�2�2�4�4�4�4����
��Ns3�!�5C�!B�8!C�B2�/C�1B2�2C�Cc���|�\|j��d���}|�<|j����t||jjjd��dSdSt
||jj��sQtd|�d�j	j
�d|j����d|jjj	j
�d�	����jj
�%tj�j|����j_
|jj
�%tj|j����|j_
tj|���std	|z���t%�fd
�|jjjD����}t)|jjj��D]!\}}t||j||���"|j��|��|jj�|���dS)a�
        Set the related instance through the reverse relation.

        With the example above, when setting ``place.restaurant = restaurant``:

        - ``self`` is the descriptor managing the ``restaurant`` attribute
        - ``instance`` is the ``place`` instance
        - ``value`` is the ``restaurant`` instance on the right of the equal sign

        Keep in mind that ``Restaurant`` holds the foreign key to ``Place``.
        Nrbrprqr*rrrsr=rtc3�B�K�|]}t�|j��V��dSr�r�rr�s  �rr�z4ReverseOneToOneDescriptor.__set__.<locals>.<genexpr>�s/�����w�w�E�w�x���?�?�w�w�w�w�w�wr)r�rerrrr0rur�rwrgrxr�ryrzrr{r|r}�tuplerL�	enumerate�local_related_fieldsrrR)rrrrZr��indexrs `     rrz!ReverseOneToOneDescriptor.__set__�s��� �=��l�3�3�H�d�3�K�K�G��"���0�0��:�:�:�����!3�!8�$�?�?�?�?�?�
#�"��E�4�<�#=�>�>�	A��*��E�E��N�.�.�.��L�2�2�4�4�4�4��L�.�4�@�@�@�	���
���!�)�%+�%8��9K�V[�%\�%\�%\���"��|��&�"(�"5�e�o�PX�"Y�"Y�"Y�����(���9�9�
t� �!j�mr�!r�s�s�s��w�w�w�w�T�\�M_�Mv�w�w�w�w�w�J� )�$�,�*<�*Q� R� R�
A�
A���u���u�}�j��.?�@�@�@�@�
�L�)�)�(�E�:�:�:�
�L��/�/��x�@�@�@�@�@rc�@�t|jj|jjffSr)r�r�r-r0r1s rr�z$ReverseOneToOneDescriptor.__reduce__�s�����+�T�\�->�?�?�?rr)
rrr r�r&rr)rr;r[rnrr�r!rrr�r�Fs�������
�
����
�
�
��_�
�0�0�0�V�V�V�a�a�a�a�$-�-�-�-�^9A�9A�9A�v@�@�@�@�@rr�c�B�eZdZdZd�Zed���Zdd�Zd�Zd�Z	dS)	�ReverseManyToOneDescriptora�
    Accessor to the related objects manager on the reverse side of a
    many-to-one relation.

    In the example::

        class Child(Model):
            parent = ForeignKey(Parent, related_name='children')

    ``Parent.children`` is a ``ReverseManyToOneDescriptor`` instance.

    Most of the implementation is delegated to a dynamically defined manager
    class built by ``create_forward_many_to_many_manager()`` defined below.
    c�,�||_|j|_dSr)�relr)rr�s  rr&z#ReverseManyToOneDescriptor.__init__�s������Y��
�
�
rc�X�|jj}t|jj|j��Sr)r�r��"create_reverse_many_to_one_manager�_default_managerr|�rr�s  r�related_manager_clsz.ReverseManyToOneDescriptor.related_manager_clss,����.�
�1��*�4��H�
�
�	
rNc�4�|�|S|�|��S)a9
        Get the related objects through the reverse relation.

        With the example above, when getting ``parent.children``:

        - ``self`` is the descriptor managing the ``children`` attribute
        - ``instance`` is the ``parent`` instance
        - ``cls`` is the ``Parent`` class (unused)
        )r�)rrrjs   rrnz"ReverseManyToOneDescriptor.__get__s#�����K��'�'��1�1�1rc�8�d|j���fS)Nzreverse side of a related set)r�r�r1s r�_get_set_deprecation_msg_paramsz:ReverseManyToOneDescriptor._get_set_deprecation_msg_paramss ��+��H�&�&�(�(�
�	
rc�J�td|���z���)Nz@Direct assignment to the %s is prohibited. Use %s.set() instead.)�	TypeErrorr�rs   rrz"ReverseManyToOneDescriptor.__set__ s+���N��2�2�4�4�
5�
�
�	
rr)
rrr r�r&rr�rnr�rr!rrr�r��sz������
�
�����
�
��_�
�
2�
2�
2�
2�
�
�
�
�
�
�
�
rr�c�,���G��fd�d|����S)z�
    Create a manager for the reverse side of a many-to-one relation.

    This manager subclasses another manager, generally the default manager of
    the related model, and adds behaviors specific to many-to-one relations.
    c�6���eZdZ��fd�Z�fd�ZdZd�Zd�Z�fd�Zd�fd�	Z	dd	�d
�Z
de
_��fd�Zde_��fd�Z
de
_��fd
�Zde_�jjr$dd	�d�Zde_dd	�d�Zde_d�Zde_ddd�d�Zde_�xZS)�:create_reverse_many_to_one_manager.<locals>.RelatedManagerc���t�����||_�j|_�j|_|jj|i|_dSr)r�r&rr�r-rr0�core_filters)rrr|r�s  ��rr&zCcreate_reverse_many_to_one_manager.<locals>.RelatedManager.__init__0sJ����G�G������$�D�M��*�D�J���D�J�!%���(� ;�D���rc�x��t|j|��}t|j���}||j��Sr)r�r-r�r|r)r�manager�
manager_classr�s   �r�__call__zCcreate_reverse_many_to_one_manager.<locals>.RelatedManager.__call__9s9����d�j�'�2�2�G�>�w�?P�RU�V�V�M� �=���/�/�/rTc�����jptj�j�j���}t
|jj}|��j����jr|�	�j��}d|_
|jdi�j��}�j
jD]<}t�j|j��}|�|dkr|r|���cS�=�j
jr�	�j
j}t�j|j��}nM#t($r@t+�fd��j
���djD����}YnwxYw�j
|�jii|_|S)�X
            Filter the queryset for the instance this manager is bound to.
            r=TN�c�D��g|]}t�j|j����Sr!)r�rr)r@�target_fieldrs  �rr�zacreate_reverse_many_to_one_manager.<locals>.RelatedManager._apply_rel_filters.<locals>.<listcomp>Xs8���(�(�(�(� ��
�|�/C�D�D�(�(�(r���r!)�_dbr�db_for_readr-rr�features�!interprets_empty_strings_as_nullsrI�using�_defer_next_filterrPr�rrLr�r�none�many_to_oner�rr��
get_path_info�
target_fields�_known_related_objects)rrUrz�empty_strings_as_nullr�valr��
rel_obj_ids`       r�_apply_rel_filterszMcreate_reverse_many_to_one_manager.<locals>.RelatedManager._apply_rel_filters?s������S�V�/��
�T�]�S�S�S�B�$/��O�$<�$^�!�������7�7�7��x�
4�#�>�>�$�(�3�3��*.�H�'�&�x��;�;��):�;�;�H���:�
+�
+���d�m�U�]�;�;���;�3�"�9�9�1F�9�#�=�=�?�?�*�*�*���z�%�
\�

N�#'�:�#:�L�")����8L�!M�!M�J�J��"����"'�(�(�(�(�,0�J�,D�,D�,F�,F�r�,J�,X�(�(�(�"�"�J�J�J�����48�:�
�D�M�?Z�2[��/��Os�+D�AE�Ec��	|jj�|jj�����dS#ttf$rYdSwxYwr)r�_prefetched_objects_cache�poprr,rSr/rfr1s r�_remove_prefetched_objectszUcreate_reverse_many_to_one_manager.<locals>.RelatedManager._remove_prefetched_objectsas^��
��
�7�;�;�D�J�<S�<b�<b�<d�<d�e�e�e�e�e��"�H�-�
�
�
����
���s�;?�A�Ac���	|jj|jj���S#t
tf$r8t�����}|�	|��cYSwxYwr)
rr�rr,rSr/rfr�r;r��rrUr|s  �rr;zGcreate_reverse_many_to_one_manager.<locals>.RelatedManager.get_querysetgsx���
9��}�>�t�z�?V�?e�?e�?g�?g�h�h��"�H�-�
9�
9�
9� �7�7�/�/�1�1���.�.�x�8�8�8�8�8�
9���s�-1�AA:�9A:Nc���	�|� t�����}|�|d���|�|jp|j��}|jj}|jj�	�	fd�|D��}d|jjz|i}|j	di|��}|D].}|||��}t||jj|���/|jj���}||�	d|dfS)Nrr=c�(��i|]}�|��|��Sr!r!r?s  �rrCzdcreate_reverse_many_to_one_manager.<locals>.RelatedManager.get_prefetch_queryset.<locals>.<dictcomp>ws%���N�N�N�D�m�m�D�1�1�4�N�N�NrrFFr!)
r�r;rIr�r�rrKrJr0rPrr,rS)rrTrUrVrWrYrZr�
cache_namerBr|s         @�rr[zPcreate_reverse_many_to_one_manager.<locals>.RelatedManager.get_prefetch_querysetns������ �7�7�/�/�1�1������1���6�6�6��~�~�h�l�&>�d�h�?�?�H��:�=�L� �J�@�M�N�N�N�N�I�N�N�N�N���
��/��;�E�&�x��/�/��/�/�H�$�
<�
<��)�,�,�w�*?�*?�@�������(�;�;�;�;���0�?�?�A�A�J��\�=�%��U�R�Rr��bulkc�|������tj�j�j���}�fd�}|r�g}|D]U}||��|jjs|jj|krtd|z���|�	|j
���V�jj�|���
|���jdi�jj�ji��dSt#j|d���5|D]!}||��|����"	ddd��dS#1swxYwYdS)Nr=c���t|�j��s$td�jjj�d|�����t|�jj�j��dS)N�'�' instance expected, got )	rur-r�rgrxrrr0r)r�rs �r�check_and_update_objz\create_reverse_many_to_one_manager.<locals>.RelatedManager.add.<locals>.check_and_update_obj�se���!�#�t�z�2�2��#�)��
�(�4�4�4�c�c�%������T�Z�_�d�m�<�<�<�<�<rzA%r instance isn't saved. Use bulk=False or save the object first.��pk__inF�r��	savepointr!)r�rr{r-rryr�rzrw�appendr�r7r�rP�updaterr0r�atomic�save)rr��objsrzr��pksr�s`      r�addz>create_reverse_many_to_one_manager.<locals>.RelatedManager.add�s�����+�+�-�-�-��$�T�Z�$�-�H�H�H�B�
=�
=�
=�
=�
=��
#����'�'�C�(�(��-�-�-��z�(��C�J�M�R�,?�,?�(�0�25�6�����J�J�s�v�&�&�&�&�L��
�(�.�.�r�2�2�9�9��9�E�E�L����J�O�T�]�P������!�'�b�E�B�B�B�#�#�#�#�#��,�,�S�1�1�1����
�
�
�
�#�#�#�#�#�#�#�#�#�#�#�#�#����#�#�#�#�#�#s�>%D1�1D5�8D5c����|j||jj<tj|j|j���}t
�|�|����jdi|��S�Nr=r!)	rrr0rr{r-r�r8�create�rr�rz�RelatedManagerr|s   ��rrzAcreate_reverse_many_to_one_manager.<locals>.RelatedManager.create�s[���&*�m�F�4�:�?�#��$�T�Z�$�-�H�H�H�B�D�5������)<�)<�=�=�D�N�N�v�N�N�Nrc����|j||jj<tj|j|j���}t
�|�|����jdi|��Sr)	rrr0rr{r-r�r8�
get_or_creaters   ��rr	zHcreate_reverse_many_to_one_manager.<locals>.RelatedManager.get_or_create�s[���&*�m�F�4�:�?�#��$�T�Z�$�-�H�H�H�B�K�5������)<�)<�=�=�K�U�U�f�U�U�Urc����|j||jj<tj|j|j���}t
�|�|����jdi|��Sr)	rrr0rr{r-r�r8�update_or_creaters   ��rrzKcreate_reverse_many_to_one_manager.<locals>.RelatedManager.update_or_create�s\���&*�m�F�4�:�?�#��$�T�Z�$�-�H�H�H�B�N�5������)<�)<�=�=�N�X�X�QW�X�X�Xrc��|sdS|j�|j��}t��}|D]�}t	||j��s$t
d|jjj�d|�����|j�	|��|kr|�
|j���t|jjj�
|�d|j�d����|�|�|���|��dS)Nr�r�z is not related to r*r�)rrJr�setrur-r�rgrxrKrr�r,r.�_clearrP)rr�rr��old_idsr�s      r�removezAcreate_reverse_many_to_one_manager.<locals>.RelatedManager.remove�s�����F��j�:�:�4�=�I�I���%�%�����C�%�c�4�:�6�6��'�i� �J�,�8�8�8�#�#�)�����z�9�9�#�>�>�#�E�E����C�F�+�+�+�+�"�j�5�;�H�H�:=�#�#�t�}�}�}�M�������D�K�K�w�K�7�7��>�>�>�>�>rc�2�|�||��dSr)r)rr�s  r�clearz@create_reverse_many_to_one_manager.<locals>.RelatedManager.clear�s�����D�$�'�'�'�'�'rc��|���tj|j|j���}|�|��}|r|jdi|jjdi��dStj
|d���5|D]>}t||jjd��|�|jjg����?	ddd��dS#1swxYwYdS)Nr=Fr�)�
update_fieldsr!)
r�rr{r-rr�r�rr0rr�rr�)rrUr�rzr�s     rrzAcreate_reverse_many_to_one_manager.<locals>.RelatedManager._clear�sG���/�/�1�1�1��(���d�m�L�L�L��#�>�>�"�-�-���F�#�H�O�>�>�t�z���&=�>�>�>�>�>�$�+�"��F�F�F�F�F�#+�F�F�C�#�C����$�?�?�?��H�H�D�J�O�3D�H�E�E�E�E�F�F�F�F�F�F�F�F�F�F�F�F�F����F�F�F�F�F�Fs�=AC
�
C�CF)r�rc�L�t|��}|jjr�tj|j|j���}tj|d���5|r$|�	|���|j
|d|i�n�t|�|���
����}g}|D]1}||vr|�|���|�|���2|j|d|i�|j
|d|i�ddd��dS#1swxYwYdS|j
|d|i�dS)Nr=Fr�r�r�)r�rrirr{r-rrr�rrr
r�r9rr�)rrr�rrz�old_objs�new_objsr�s        rr
z>create_reverse_many_to_one_manager.<locals>.RelatedManager.set�s�����;�;�D��z��
+��(���d�m�L�L�L�� �'�b�E�B�B�B�7�7��
7��
�
��
�-�-�-� ���$�2�T�2�2�2�2�#&�t�z�z�"�~�~�'9�'9�';�';�#<�#<��#%��#'�5�5�C�"�h��� (���� 4� 4� 4� 4� (���� 4� 4� 4� 4�#���X�9�D�9�9�9� ���(�6��6�6�6�7�7�7�7�7�7�7�7�7�7�7�7����7�7�7�7�7�7� ���$�*�T�*�*�*�*�*s�B+D
�
D�Dr)rrr r&r��do_not_call_in_templatesr�r�r;r[r�alters_datarr	rrrirrrr
r�)r|rr�s@��rrr�/s���������	<�	<�	<�	<�	<�	<�	0�	0�	0�	0�	0�$(� � 	� 	� 	�D	�	�	�	9�	9�	9�	9�	9�	S�	S�	S�	S�	S�	S�*#'�	#�	#�	#�	#�	#�:���	O�	O�	O�	O�	O�	O�"���	V�	V�	V�	V�	V�	V�%)�
�!�	Y�	Y�	Y�	Y�	Y�	Y�(,��$��9�>�%	&�)-�
?�
?�
?�
?�
?�$"&�F��$(�
(�
(�
(�
(�
(� $�E��
F�
F�
F�"&�F��$(��	+�	+�	+�	+�	+�0������rrr!)�
superclassr�rs `@rr�r�'sQ����E�E�E�E�E�E�E�E��E�E�E�N�rc�V��eZdZdZd�fd�	Zed���Zed���Zd�Z	�xZ
S)�ManyToManyDescriptora�
    Accessor to the related objects manager on the forward and reverse sides of
    a many-to-many relation.

    In the example::

        class Pizza(Model):
            toppings = ManyToManyField(Topping, related_name='pizzas')

    ``Pizza.toppings`` and ``Topping.pizzas`` are ``ManyToManyDescriptor``
    instances.

    Most of the implementation is delegated to a dynamically defined manager
    class built by ``create_forward_many_to_many_manager()`` defined below.
    Fc�X��t���|��||_dSr)r�r&�reverse)rr�rr|s   �rr&zManyToManyDescriptor.__init__
s&���
�������������rc��|jjSr)r��throughr1s rr zManyToManyDescriptor.throughs��
�x��rc��|jr|jjn|jj}t	|jj|j|j���S)N)r)rr�r�r-�#create_forward_many_to_many_managerr�r|r�s  rr�z(ManyToManyDescriptor.related_manager_clssF��26�,�R���.�.�D�H�N�
�2��*�4��H��L�
�
�
�	
rc�v�d|jrdndz|jr|j���n|jjfS)Nz%s side of a many-to-many setr�forward)rr�r�rr0r1s rr�z4ManyToManyDescriptor._get_set_deprecation_msg_params s@��+�D�L�/W�y�y�i�X�,0�L�M�D�H�&�&�(�(�(�d�j�o�
�	
r)F)rrr r�r&�propertyr rr�r�r�r�s@rrr�s���������� ������
� � ��X� ��
�
��_�
�
�
�
�
�
�
�
rrc�0����G���fd�d|����S)z�
    Create a manager for the either side of a many-to-many relation.

    This manager subclasses another manager, generally the default manager of
    the related model, and adds behaviors specific to many-to-many relations.
    c�H���eZdZd���fd�	Z��fd�ZdZd�Zd�Zd�Z�fd�Z	d�fd	�	Z
dd
�d�Zde_d�Z
de
_�fd
�Zde_ddd�d�Zde_dd
���fd�
Zde_dd
���fd�
Zde_dd
���fd�
Zde_d�Zd�Zd�Zdd
�d�Z�fd�Z�xZS)�?create_forward_many_to_many_manager.<locals>.ManyRelatedManagerNc����t�����||_�s��j|_�j���|_�jj|_�j�	��|_
�j���|_�j
|_
n~�j|_�jj|_�j���|_�j���|_
�j�	��|_d|_
�j|_�|_|jj�|j
��|_|jj�|j��|_i|_i|_|jjD]G\}}|j�d|j��}t1||j��|j|<|j|j|j<�H|j�|��|_d|jvr&t9d|�d|j|j
�d����|j�t9d|jjz���dS)NF�__�"z#" needs to have a value for field "z4" before this many-to-many relationship can be used.z]%r instance needs to have a primary key value before a many-to-many relationship can be used.) r�r&rr-rrO�query_field_namer0�prefetch_cache_name�m2m_field_name�source_field_name�m2m_reverse_field_name�target_field_name�symmetricalr�r rrg�	get_field�source_fieldr�r��pk_field_namesr~r�rrJ�related_valrwr�r|r)rrr�r��core_filter_keyr|r�rs     ���rr&zHcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.__init__0s?����G�G������$�D�M��

)� �Y��
�(+�	�(D�(D�(F�(F��%�+.�9�>��(�),��)A�)A�)C�)C��&�),��)I�)I�)K�)K��&�#&�?�� � � �.��
�(+�	���%�+.�9�+G�+G�+I�+I��(�),��)I�)I�)K�)K��&�),��)A�)A�)C�)C��&�#(�� ��;�D�L�"�D�L� $�� 2� <� <�T�=S� T� T�D�� $�� 2� <� <�T�=S� T� T�D�� "�D��"$�D��&*�&7�&F�
C�
C�"��(�.2�.C�.C�.C�X�]�]�"S��5<�X�x�GW�5X�5X��!�/�2�5=�]��#�H�M�2�2�#�0�J�J�8�T�T�D���t�'�'�'� �j�"*�(�(�D�,?��@V�,W�,W�,W�"Y�Z�Z�Z��{�"� �"L�!)�!3�!<�"=�>�>�>�#�"rc�|��t|j|��}t|j����}||j���Sr])r�r-r"r|r)rr�r�r�rs   ��rr�zHcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.__call__^s?����d�j�'�2�2�G�?��@Q�SV�X_�`�`�M� �=�$�-�8�8�8�8rTc�>�tdi|j|ji��}t|t��p|���}|r|tdid|jz|i��z}|jr8tdi|j|ji��}|r|tdid|jz|i��z}||z}|S)NrFr!)rr/r6rur	�_has_filtersr1r2)r�removed_vals�filters�removed_vals_filters�symmetrical_filterss     r�_build_remove_filterszUcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager._build_remove_filtersds����E�E�4�1�4�3C�D�E�E�G�)3�<��(J�(J�$J�%@�$0�$=�$=�$?�$?�
!�#�
R��1�Q�Q��4�+A� A�<�P�Q�Q�Q����
/�&'�&U�&U�4�+A�4�CS�*T�&U�&U�#�'�M�'�1�,M�,M�#�d�&<�<�l�K�,M�,M�M�'��.�.���Nrc���|�|j���|jr|�|j��}d|_|���jdi|j��S)r�r=Tr!)rIrr�r�r��_next_is_stickyrPr�)rrUs  rr�zRcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager._apply_rel_filterstsj��
������7�7�7��x�
4�#�>�>�$�(�3�3��*.�H�'�4�8�+�+�-�-�4�I�I�t�7H�I�I�Irc��	|jj�|j��dS#tt
f$rYdSwxYwr)rr�r�r-r/rfr1s rr�zZcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager._remove_prefetched_objects~sP��
��
�7�;�;�D�<T�U�U�U�U�U��"�H�-�
�
�
����
���s�$(�=�=c����	|jj|jS#ttf$r8t�����}|�|��cYSwxYwr)rr�r-r/rfr�r;r�r�s  �rr;zLcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.get_queryset�sj���
9��}�>�t�?W�X�X��"�H�-�
9�
9�
9� �7�7�/�/�1�1���.�.�x�8�8�8�8�8�
9���s��AA#�"A#c�>������|� t�����}|�|d���|�|jp|j��}d|jz|i}|���jd	i|��}|jj	�
|j����jj	j
�t|j��jj�|���fd��jD�����}|�fd���fd�d|jdfS)
Nrr=rFc�^��i|])}d|jz�����d�|j������*S)�_prefetch_related_val_%sr*)r�column)r@�f�
join_table�qns  ��rrCzicreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.get_prefetch_queryset.<locals>.<dictcomp>�sV���.[�.[�.[�=>�+�Q�Y�6��2�j�>�>�>�>�2�2�a�h�<�<�<�8�.[�.[�.[r)�selectc�F���t�fd��jD����S)Nc3�H�K�|]}t�d|jz��V��dS)rFNr�)r@rH�results  �rr�zzcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.get_prefetch_queryset.<locals>.<lambda>.<locals>.<genexpr>�sI�����%�%���F�$>���$J�K�K�%�%�%�%�%�%r)r�r�)rN�fks`�r�<lambda>zgcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.get_prefetch_queryset.<locals>.<lambda>�s;����u�%�%�%�%��4�%�%�%� � �rc�H���t��fd��jD����S)Nc3�j�K�|]-}|�t�|j�����V��.dSr)�get_db_prep_valuer�r)r@rH�
connectionrAs  ��rr�zzcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.get_prefetch_queryset.<locals>.<lambda>.<locals>.<genexpr>�sS�����#�#���'�'���a�i�(@�(@�*�M�M�#�#�#�#�#�#r)r�rL)rArTrOs`��rrPzgcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.get_prefetch_queryset.<locals>.<lambda>�s@����U�#�#�#�#�#��6�#�#�#���rFr!)r�r;rIr�r�r,rArPr rgr3r/r-�db_tablerrz�ops�
quote_name�extrar�r-)	rrTrUrYrTrOrIrJr|s	    @@@@�rr[zUcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.get_prefetch_queryset�sc��������� �7�7�/�/�1�1������1���6�6�6��~�~�h�l�&>�d�h�?�?�H��� 5�5�y�A�E�8�x�/�/�1�1�8�A�A�5�A�A�H���#�-�-�d�.D�E�E�B����0�J�$�X�[�1�J���*�B��~�~�.[�.[�.[�.[�.[�BD�BY�.[�.[�.[�~�\�\�H�������������(��
�

r��through_defaultsc�J�|���tj|j|j���}tj|d���5|j|j|j	g|�Rd|i�|j
r|j|j	|jg|�Rd|i�ddd��dS#1swxYwYdS)Nr=Fr�rZ)r�rr{r rrr��
_add_itemsr/r1r2)rrZrrzs    rrzCcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.add�s/���+�+�-�-�-��$�T�\�D�M�J�J�J�B��#�"��>�>�>�

�

�����*�D�,B��EI����%5�����#��#�D�O��.��.������*:�	���

�

�

�

�

�

�

�

�

�

�

�

����

�

�

�

�

�

s�AB�B�Bc�`�|���|j|j|jg|�R�dSr)r��
_remove_itemsr/r1)rrs  rrzFcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.remove�s>���+�+�-�-�-��D��t�5�t�7M�U�PT�U�U�U�U�U�Urc
����tj|j|j���}t	j|d���5tj�|jd|j|j	|j
d|���|���|�t������|����}|jj�|���|�����tj�|jd|j|j	|j
d|���ddd��dS#1swxYwYdS)Nr=Fr��	pre_clear��sender�actionrrr-�pk_setr��
post_clear)rr{r rrr�r�m2m_changed�sendrr-r�r?r�r;r�r�rP�delete)rrzr<r|s   �rrzEcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.clear�s�����$�T�\�D�M�J�J�J�B��#�"��>�>�>�
�
��#�(�(��<��!�]�D�L��*�T��)����
�/�/�1�1�1��4�4�U�W�W�5I�5I�5K�5K�5Q�5Q�RT�5U�5U�V�V����-�3�3�B�7�7�>�>�w�G�G�N�N�P�P�P��#�(�(��<��!�]�D�L��*�T��)����
�
�
�
�
�
�
�
�
�
�
�
����
�
�
�
�
�
s�DE�E�EF)rrZc���t|��}tj|j|j���}tj|d���5|r"|���|j|d|i�n�t|�
|���|jjj
d�����}g}|D]�}t||j��r |j�|��dn|j�|��}||vr|�|���k|�|����|j|�|j|d|i�ddd��dS#1swxYwYdS)Nr=Fr�rZT��flatr)r�rr{r rrr�rrr
r��values_listr�rrur-rJ�get_prep_valuerr�)	rrrrZrzrrr��fk_vals	         rr
zCcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.set�s�����;�;�D��$�T�\�D�M�J�J�J�B��#�"��>�>�>�
K�
K��K��J�J�L�L�L��D�H�d�F�5E�F�F�F�F�!�$�*�*�R�.�.�"<�"<�T�=N�=[�=c�jn�"<�"o�"o�p�p�G�!�H�#�	1�	1�� *�#�t�z�:�:�G�D�-�G�G��L�L�Q�O�O�!%�!2�!A�!A�#�!F�!F��
"�W�,�,�#�N�N�6�2�2�2�2�$�O�O�C�0�0�0�0��D�K��)�)��D�H�h�J�9I�J�J�J�)
K�
K�
K�
K�
K�
K�
K�
K�
K�
K�
K�
K����
K�
K�
K�
K�
K�
Ks�DE�E�!Ec����tj|jj|j���}t	�|�|����jdi|��}|�||���|S�Nr=rYr!)rr{rr|r�r8rr)rrZr�rz�new_obj�ManyRelatedManagerr|s     ��rrzFcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.create�sj����$�T�]�%<�t�}�U�U�U�B�K�e�.�����0C�0C�D�D�K�U�U�f�U�U�G��H�H�W�/?�H�@�@�@��Nrc����tj|jj|j���}t	�|�|����jdi|��\}}|r|�||���||fSrp)rr{rr|r�r8r	r�rrZr�rzr��createdrrr|s      ��rr	zMcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.get_or_creates����$�T�]�%<�t�}�U�U�U�B�W�5�!3�T�_�_�R�5H�5H�I�I�W�a�a�Z`�a�a�L�C���
A�����/?��@�@�@���<�rc����tj|jj|j���}t	�|�|����jdi|��\}}|r|�||���||fSrp)rr{rr|r�r8rrrts      ��rrzPcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.update_or_creates����$�T�]�%<�t�}�U�U�U�B�Z�5�!3�T�_�_�R�5H�5H�I�I�Z�d�d�]c�d�d�L�C���
A�����/?��@�@�@���<�rc
��ddlm}t��}|jj�|��}|D�]	}t
||j��r�tj	||j
��s2td|�d|j
jj
�d|jj
�d����|�|��d}|�td|�d|�d	����|�|����t
||��r$t!d
|jjj�d|�����|�|�|������|S)z[
            Return the set of ids of `objs` that the target field references.
            r)�ModelzCannot add "z": instance is on database "z", value is on database "r+Nz": the value for field "z	" is Noner�r�)�django.db.modelsrxr
r rgr3rur-rr}rrwryrzrJrr�rxrm)rr1rrx�
target_idsr�r��	target_ids        r�_get_target_idszOcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager._get_target_idss~��
/�.�.�.�.�.����J��<�-�7�7�8I�J�J�L��
E�
E���c�4�:�.�.�E�!�0��d�m�D�D��(�j�!�S�S�$�-�"6�"9�"9�"9�3�:�=�=�=�J����
!-� F� F�s� K� K�A� N�I� �(�(�j� �S�S�"3�"3�"3�5�����N�N�9�-�-�-�-���U�+�+�E�#�)���)�5�5�5�s�s�<����
�N�N�<�#>�#>�s�#C�#C�D�D�D�D��rc���|jj�|���|d���jdi||jdd|z|i��}|�|��S)z{
            Return the subset of ids of `objs` that aren't already assigned to
            this relationship.
            TrjrrFr!)r r�r�rlrPr6�
difference)rr/r1rzrz�valss      r�_get_missing_target_idszWcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager._get_missing_target_ids4s���
�4�<�0�6�6�r�:�:�F�F�!��G������"�4�#3�A�#6��,�,�j����D��(�(��.�.�.rc���t|jjo|jjjdu}|js||jko#tj	�
|j��}|||o|fS)aw
            Return a boolean triple of the way the add should be performed.

            The first element is whether or not bulk_create(ignore_conflicts)
            can be used, the second whether or not signals must be sent, and
            the third element is whether or not the immediate bulk insertion
            with conflicts ignored can be performed.
            F)rr��supports_ignore_conflictsr rg�auto_createdrr/rrf�
has_listeners)rrzr/�can_ignore_conflicts�must_send_signalss     r�
_get_add_planzMcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager._get_add_planAsz���B��(�B�=���"�/�u�<�
!�"&��!\�1B�d�F\�1\�!��#�1�1�$�,�?�?�
�(�):�=Q�=k�Zk�Vk�l�lrc
������|sdStt�pi��������|��}tj�j�j���}��|���\}}}	|	rD�jj�	|���
���fd�|D��d���dS����||��}
tj
|d���5|r:tj��jd�j�j�j|
|����jj�	|���
����fd	�|
D��|���|r:tj��jd
�j�j�j|
|���ddd��dS#1swxYwYdS)Nr=c
�T��g|]$}�jdid�z�jdd�z|i����%S�z%s_idrr!�r r6)r@r{rr/r1s  ���rr�z^create_forward_many_to_many_manager.<locals>.ManyRelatedManager._add_items.<locals>.<listcomp>jsl���E�E�E�
"�	!�D�L����"3�3�T�5E�a�5H��"3�3�Y�$���E�E�ErT)�ignore_conflictsFr��pre_addrac
�X��g|]&}�jdi��d�z�jdd�z|i����'Sr�r�)r@r{rr/r1rZs  ����rr�z^create_forward_many_to_many_manager.<locals>.ManyRelatedManager._add_items.<locals>.<listcomp>~st���E�E�E�
"�	!�D�L���#3���"3�3�T�5E�a�5H��"3�3�Y�8���E�E�Er�post_add)�dictrr|rr{r rr�r�r��bulk_creater�rr�rrfrgrr-)rr/r1rZrrzrzr�r��can_fast_add�missing_target_idss````       rr\zJcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager._add_items^s��������
���#�$5�6F�6L�"�$M�$M�N�N���-�-�.?��F�F�J��$�T�\�D�M�J�J�J�B�DH�DV�DV�WY�[l�Dm�Dm�A� �"3�\��
���-�3�3�B�7�7�C�C�E�E�E�E�E�E�
&0�E�E�E�%)�
D�*�*�*���!%�!=�!=�!�#4�b�*�"�"���#�"��>�>�>�
�
�$���'�,�,�#�|�I�!%����"�j�1C�2�-������-�3�3�B�7�7�C�C�E�E�E�E�E�E�E�
&8�E�E�E�%9�
D�:�:�:�%���'�,�,�#�|�J�!%����"�j�1C�2�-����#
�
�
�
�
�
�
�
�
�
�
�
����
�
�
�
�
�
s�+B<F4�4F8�;F8c
���|sdSt��}|D]b}t||j��r6|j�|��d}|�|���M|�|���ct
j|j|j	���}tj|d���5tj
�|jd|j	|j|j||���t!�����}|���r5|�|��jd	id|jjjz|i��}	n|}	|�|	��}
|jj�|���|
�����tj
�|jd|j	|j|j||���ddd��dS#1swxYwYdS)
Nrr=Fr��
pre_removerarF�post_remover!)r
rur-r�rJrrr{r rrr�rrfrgrr�r;r:r�rPrr?r�rh)rr/r1rrr�rnrz�target_model_qs�old_valsr<r|s           �rr^zMcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager._remove_items�sN���
�
����e�e�G��
%�
%���c�4�:�.�.�%�!�.�H�H��M�M�a�P�F��K�K��'�'�'�'��K�K��$�$�$�$��$�T�\�D�M�J�J�J�B��#�"��>�>�>�
�
��#�(�(��<��!�]�D�L��*�W�B�)����
#(�'�'�"6�"6�"8�"8��"�/�/�1�1�'�?��4�4�R�8�8�?� U� U� �4�#4�#A�#I�I�7�CT� U� U�H�H� '�H��4�4�X�>�>����-�3�3�B�7�7�>�>�w�G�G�N�N�P�P�P��#�(�(��<�
�!�]�D�L��*�W�B�)����!
�
�
�
�
�
�
�
�
�
�
�
����
�
�
�
�
�
s�/D9G5�5G9�<G9r)rrr r&r�rr?r�r�r;r[rrrrr
rr	rr|r�r�r\r^r�)r|rrr�rs@���rrrr(/ss��������,	>�,	>�,	>�,	>�,	>�,	>�,	>�,	>�\	9�	9�	9�	9�	9�	9�$(� �	�	�	� 	J�	J�	J�	�	�	�	9�	9�	9�	9�	9�%	�%	�%	�%	�%	�%	�N/3�	�	�	�	�	�"���	V�	V�	V�"���	�	�	�	�	�"!���%*�T�	K�	K�	K�	K�	K�6���-1�	�	�	�	�	�	�	�	�
"���48�	 �	 �	 �	 �	 �	 �	 �	 �%)�
�!�7;�	 �	 �	 �	 �	 �	 �	 �	 �(,��$�	�	�	�>	/�	/�	/�	m�	m�	m�:\`�-	�-	�-	�-	�-	�^&	�&	�&	�&	�&	�&	�&	�&	�&	rrrr!)rr�rrrs ``@rr"r"'sX�����D�D�D�D�D�D�D�D�D�Z�D�D�D�L�rN)r��django.core.exceptionsr�	django.dbrrrryrr�django.db.models.queryr	�django.db.models.query_utilsr
�django.db.models.utilsr�django.utils.functionalrrr#r�r�r�r�rr"r!rr�<module>r�s���?�?�B.�-�-�-�-�-�6�6�6�6�6�6�6�6�6�6�'�'�'�'�'�'�'�'�+�+�+�+�+�+�:�:�:�:�:�:�4�4�4�4�4�4�3�3�3�3�3�3�6�6�6�6�6�"3�6�6�6�A<�A<�A<�A<�A<�A<�A<�A<�H-@�-@�-@�-@�-@� :�-@�-@�-@�`e@�e@�e@�e@�e@�e@�e@�e@�P6
�6
�6
�6
�6
�6
�6
�6
�rO�O�O�d+
�+
�+
�+
�+
�5�+
�+
�+
�\N�N�N�N�Nr

Youez - 2016 - github.com/yon3zu
LinuXploit