+
    TjZ                     T   R t ^ RIHt ^ RIHt ^ RIHtHtHtH	t	H
t
 ^ RIHtHtHtHt ^ RIHt ^ RIHt ^ RIHt ^ RIHtHt ^ R	IHt ^ R
IHt ^ RIHtHt ^ RI H!t!  ! R R]4      t"R t#R t$ ! R R4      t% ! R R]%4      t& ! R R4      t' ! R R4      t(R t) ! R R](4      t*R t+R# )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.
)sync_to_async)
FieldError)DEFAULT_DB_ALIASNotSupportedErrorconnectionsroutertransaction)ManagerQWindowsignals)ColPairs)TupleIn)	RowNumber)GreaterThanLessThanOrEqual)QuerySet)DeferredAttribute)
AltersDataresolve_callables)cached_propertyc                   &   a  ] tR t^Wt o R tRtV tR# )ForeignKeyDeferredAttributec                *   VP                   P                  V P                  P                  4      V8w  d=   V P                  P	                  V4      '       d   V P                  P                  V4       W!P                   V P                  P                  &   R # N)__dict__getfieldattname	is_cacheddelete_cached_valueselfinstancevalues   &&&`/var/www/idalgo/venv/lib/python3.14/site-packages/django/db/models/fields/related_descriptors.py__set__#ForeignKeyDeferredAttribute.__set__X   sl      !3!34=$**BVBVC
 C
 JJ**8405$**,,-     N)__name__
__module____qualname____firstlineno__r&   __static_attributes____classdictcell____classdict__s   @r%   r   r   W   s     6 6r(   r   c                    \        R/ V R 2V/B pV P                  ;'       g    \        pV P                  P                  '       d   \
        V,          P                  P                  '       g   \        R4      hV P                  P                  V P                  P                  reV P                  P                  VR7      P                  4        UUu. uF  w  rxVNK	  	  p	pp\        \        4       WR7      p
V\        W4      ,          pVe   V\!        W4      ,          pV P                  P#                  4        V P                  P%                  VRR7       V # u uppi )__inz`Prefetching from a limited queryset is only supported on backends that support window functions.)using)partition_byorder_byT)	reuse_allr)   )r
   _dbr   query	is_slicedr   featuressupports_over_clauser   low_mark	high_markget_compilerget_order_byr   r   r   r   clear_limitsadd_q)queryset
field_name	instances	predicatedbr=   r>   expr_r6   windows   &&&        r%   _filter_prefetch_querysetrK   `   s#   5
|4()45I		)	))B~~2''<<<#1  'nn55x~~7O7O) ( ; ;" ; E R R T
 TWTD T 	 
 	*P[22	 ;;I##% NNd3O
s   Ec              #      "   TpVeG   VP                   P                  V 4      pV'       g	   VR 3x  R # VP                  VR 4      pW$3x  TpKJ  R # 5ir   )_metaget_ancestor_linkget_cached_value)modelstarting_instancecurrent_instanceancestor_linkancestors   &&   r%   _traverse_ancestorsrU   x   s_     (

&(..@@G"D(( 112BDI((# 's
   )A%Ac                   l   a  ] tR t^t o RtR t]R 4       tR tR t	RR lt
R tRR	 ltR
 tR tRtV tR# )ForwardManyToOneDescriptora.  
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                    Wn         R # r   r   )r"   field_with_rels   &&r%   __init__#ForwardManyToOneDescriptor.__init__   s    #
r(   c                0   \        R V P                  P                  P                  P                  \
        3RV P                  P                  P                  RV P                  P                  P                  : RV P                  P                  : R2/4      # RelatedObjectDoesNotExistr+   r,   .z.RelatedObjectDoesNotExist)	typer   remote_fieldrP   DoesNotExistAttributeErrorr+   r,   namer"   s   &r%   r_   4ForwardManyToOneDescriptor.RelatedObjectDoesNotExist   sr    
 'ZZ$$**77Hdjj..99JJ$$11JJOO!
 	
r(   c                8    V P                   P                  V4      # r   )r   r   r"   r#   s   &&r%   r   $ForwardManyToOneDescriptor.is_cached   s    zz##H--r(   c                    V P                   P                  P                  P                  P	                  VR 7      P                  4       # hints)r   rb   rP   _base_manager
db_managerallr"   rn   s   &,r%   get_queryset'ForwardManyToOneDescriptor.get_queryset   s5    zz&&,,::EEEERVVXXr(   Nc           
        V'       d   \        V4      ^8w  d   \        R4      hV'       d
   V^ ,          MV P                  4       pVP                  V^ ,          R7       V P                  P
                  pV P                  P                  pV Uu/ uF  qe! V4      VbK  	  ppV P                  P                  pV P                  P                   U	u. uF2  p	VP                  P                  V	P                  4      P                  NK4  	  p
p	VP                  \        \        VP                   P"                  P$                  V
V
V P                  4      \'        V4      4      4      pVP                  P)                  4        VP*                  '       g)   V F"  pWt! V4      ,          pVP-                  W4       K$  	  VVVRV P                  P.                  R3# u upi u up	i )   Iquerysets argument of get_prefetch_querysets() should have a length of 1.r#   TF)len
ValueErrorrs   
_add_hintsr   get_foreign_related_valueget_local_related_valuerb   foreign_related_fieldsr9   resolve_refre   targetfilterr   r   rP   rM   db_tablelistclear_orderingmultipleset_cached_value
cache_name)r"   rE   	querysetsrC   rel_obj_attrinstance_attrinstinstances_dictrb   r   related_fieldsrel_objr#   s   &&&          r%   get_prefetch_querysets1ForwardManyToOneDescriptor.get_prefetch_querysets   s   Y1,  $-9Q<$2C2C2EYq\2zz;;

::@IJ	--t3	Jzz.. ::
: NN&&uzz299: 	 
 ??NN((11""JJ	 ^$

 	%%' $$$#),w*?@--g@ $ JJ!!
 	
7 K
s   G8Gc                z    V P                  VR 7      pVP                  V P                  P                  V4      4      # rx   )rs   r   r   get_reverse_related_filter)r"   r#   qss   && r%   
get_object%ForwardManyToOneDescriptor.get_object   s3    1vvdjj;;HEFFr(   c                $   Vf   V #  V P                   P                  V4      pTfh   T P                   P                  '       gL   T P                  T P                   P                  P                  : RT P                   P                  : R24      hT#   \         d    RpRT P                   P                  T4      9  pT'       dX   T P                   P                  p\        YQ4       F2  w  rgT'       g   K  T P                   P                  TRR7      pTf   K2   M	  TfS   T'       dK   T P                  T4      pT P                   P                  pTP                  '       g   TP                  Y14       T P                   P                  Y4        ELki ; i)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   rO   KeyErrorr}   rP   rU   r   rb   r   r   nullr_   r*   re   )	r"   r#   clsr   	has_valuerP   rR   rT   rb   s	   &&&      r%   __get__"ForwardManyToOneDescriptor.__get__   sH    K
	;jj11(;G2 ?4::???00#'::#3#3#<#<djjooN  N;  	;GDJJ$F$Fx$PPI

((2Ee2V.$x #'**"="=hPT"="U".! 3W 9//(3#zz66 $,,, 11'DJJ'':-	;s/   B 2F+F3FF&8F,FFc                *   Ve   \        W P                  P                  P                  P                  P
                  4      '       gw   \        RV: RVP                  P                  : RV P                  P                  : RV P                  P                  P                  P                  P                  : R2	4      hVe   VP                  P                  f2   \        P                  ! VP                  VR7      VP                  n
        VP                  P                  f2   \        P                  ! VP                  VR7      VP                  n
        \        P                  ! W!4      '       g   \        RV,          4      hV P                  P                  pVfj   V P                  P                  VRR	7      pVe   VP!                  VR4       V P                  P"                   F  w  rV\%        WP&                  R4       K  	  MHV P                  P"                   F.  w  rV\%        WP&                  \)        W&P&                  4      4       K0  	  V P                  P!                  W4       Ve(   VP*                  '       g   VP!                  W!4       R# R# R# )
a(  
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.rx   GCannot assign "%r": the current database router prevents this relation.r   )
isinstancer   rb   rP   rM   concrete_modelrz   object_namere   _staterG   r   db_for_write	__class__allow_relationrO   r   r   setattrr   getattrr   )r"   r#   r$   rb   relatedlh_fieldrh_fields   &&&    r%   r&   "ForwardManyToOneDescriptor.__set__  s     Z::**0066EE&
 &
  NN..JJOOJJ++1177CC  !!)%+%8%8&&&" ||&"("5"5OOh# ((99  "'( 
 zz..
 = jj11(D1IG
 "--gt<&*jj&?&?""2"2D9 '@
 '+jj&?&?""2"2GECSCS4TU '@
 	

##H4
 \%:%:%:))%: &;r(   c                f    \         V P                  P                  V P                  P                  33# )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   r   rP   re   rf   s   &r%   
__reduce__%ForwardManyToOneDescriptor.__reduce__]  s&     ))4::??;;;r(   rY   r   )r*   r+   r,   r-   __doc__r[   r   r_   r   rs   r   r   r   r&   r   r.   r/   r0   s   @r%   rW   rW      sQ     
$ 
 
".Y-
^G
/bJ;X< <r(   rW   c                   B   a a ] tR tRt oRtV 3R ltV 3R ltRtVtV ;t	# )ForwardOneToOneDescriptorif  a  
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                  <a V P                   P                  P                  '       Ed   VP                  4       pV P                   P                  P                  pVP
                  P                   Uu. uF  qDP                  NK  	  upo\        ;QJ d    V3R  lV 4       F  '       g   K   RM	  RM! V3R  lV 4       4      '       go   S Uu/ uF  qD\        W4      bK  	  ppV! R/ VB pVP                  P                  VP                  n        VP                  P                  VP                  n        V# \        SV `9  V4      # u upi u upi )c              3   ,   <"   T F	  qS9   x  K  	  R # 5ir   r)   ).0r   fieldss   & r%   	<genexpr>7ForwardOneToOneDescriptor.get_object.<locals>.<genexpr>~  s     =H5Hs   TFr)   )r   rb   parent_linkget_deferred_fieldsrP   rM   concrete_fieldsr   anyr   r   addingrG   superr   )	r"   r#   deferred	rel_modelr   kwargsobjr   r   s	   &&     @r%   r   $ForwardOneToOneDescriptor.get_objects  s    ::""...335H 

//55I1:1P1PQ1Pmm1PQF
 3=H=333=H===GMNve!99vN)&)$,OO$:$:

! ( 2 2


w!(++ R Os   2EEc                  < \         SV `  W4       V P                  P                  '       d   V P                  P                  P
                  '       d   VP                  pVP                   Uu. uF-  pVP                  '       g   K  VP                  '       g   K+  VNK/  	  ppV FT  pVP                  P                  P                  P                  P                  pVe   \        W&4      MR p\        WV4       KV  	  R # R # R # u upi r   )r   r&   r   primary_keyrb   r   rM   r   rP   pkr   r   r   )	r"   r#   r$   optsr   inherited_pk_fieldsrel_model_pk_name	raw_valuer   s	   &&&     r%   r&   !ForwardOneToOneDescriptor.__set__  s    ( ::!!!djj&=&=&I&I&I>>D "11#1E$$ ).);); 1   #
 -$)$6$6$<$<$B$B$E$E$M$M!9>9JGE5PT  Y? - 'J!#s   -DDDr)   )
r*   r+   r,   r-   r   r   r&   r.   r/   __classcell__r   r1   s   @@r%   r   r   f  s     
,&@ @r(   r   c                   f   a  ] tR tRt o RtR t]R 4       tR tR t	RR lt
RR	 ltR
 tR tRtV tR# )ReverseOneToOneDescriptori  a  
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                    Wn         R # r   r   )r"   r   s   &&r%   r[   "ReverseOneToOneDescriptor.__init__  s	     r(   c                   \        R V P                  P                  P                  \        3RV P                  P
                  P                  RV P                  P
                  P                  : RV P                  P                  : R2/4      # r^   )	ra   r   related_modelrc   rd   rP   r+   r,   re   rf   s   &r%   r_   3ReverseOneToOneDescriptor.RelatedObjectDoesNotExist  sn     '\\''44nEdll00;;LL&&33LL%%!
 	
r(   c                8    V P                   P                  V4      # r   )r   r   ri   s   &&r%   r   #ReverseOneToOneDescriptor.is_cached  s    ||%%h//r(   c                ~    V P                   P                  P                  P                  VR 7      P	                  4       # rl   )r   r   ro   rp   rq   rr   s   &,r%   rs   &ReverseOneToOneDescriptor.get_queryset  s/    ||))77BBBOSSUUr(   Nc                   V'       d   \        V4      ^8w  d   \        R4      hV'       d
   V^ ,          MV P                  4       pVP                  V^ ,          R7       V P                  P
                  P                  pV P                  P
                  P                  pV Uu/ uF  qe! V4      VbK  	  ppRV P                  P
                  P                  ,          V/pVP                  ! R/ VB pVP                  P                  4        V F6  p	Wt! V	4      ,          p
V P                  P
                  P                  W4       K8  	  VVVRV P                  P                  R3# u upi )rv   rw   rx   %s__inTFr)   )ry   rz   rs   r{   r   r   r}   r|   re   r   r9   r   r   r   )r"   rE   r   rC   r   r   r   r   r9   r   r#   s   &&&        r%   r   0ReverseOneToOneDescriptor.get_prefetch_querysets  s:   Y1,  $-9Q<$2C2C2EYq\2||))AA**DD@IJ	--t3	JDLL..333Y???+U+ 	%%'  G%l7&;<HLL//B   LL##
 	
 Ks   "E"c                   Vf   V #  V P                   P                  V4      pVfB   V P                  VP                  P                  : RV P                   P                  : R24      hV#   \         d    TP                  4       '       g   RpMT P                   P                  P                  T4      p T P                  TR7      P                  ! R/ TB pT P                   P                  P                  Y14       M-  T P                   P                  P                   d    Rp Mi ; iT P                   P                  Y4        EL$i ; i)aQ  
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``.
Nrx   r   r`   r)   )r   rO   r   
_is_pk_setr   get_forward_related_filterrs   r   r   r   rc   r_   r   r*   accessor_name)r"   r#   r   r   filter_argss   &&&  r%   r   !ReverseOneToOneDescriptor.__get__  s$    K
	=ll33H=G" ?00%%..0J0JL 
 N-  	=&&(("ll00KKHUK"///BFFUUG LL&&77J ||11>> #"G# LL))(<	=s;   A* * E(E4"C<&E<'D&#E%D&&EEc                  a Vfk   V P                   P                  SRR7      pVeH   V P                   P                  S4       \        W0P                   P                  P
                  R4       R# R# \        W P                   P                  4      '       gm   \        RV: RSP                  P                  : RV P                   P                  : RV P                   P                  P                  P                  : R2	4      hSP                  P                  f2   \        P                  ! SP                   VR7      SP                  n        VP                  P                  f2   \        P                  ! VP                   SR7      VP                  n        \        P"                  ! VS4      '       g   \        R	V,          4      h\$        ;QJ d5    . V3R
 lV P                   P                  P&                   4       F  NK  	  5M.! V3R
 lV P                   P                  P&                   4       4      p\)        V P                   P                  P*                  4       F!  w  rV\        W&P,                  WE,          4       K#  	  V P                   P/                  SV4       V P                   P                  P/                  VS4       R# )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``.
Nr   r   r   r`   r   r   rx   r   c              3   P   <"   T F  p\        SVP                  4      x  K  	  R # 5ir   )r   r   )r   r   r#   s   & r%   r   4ReverseOneToOneDescriptor.__set__.<locals>.<genexpr>F  s&      FE %--00Fs   #&)r   rO   r    r   r   re   r   r   rz   rM   r   r   r   rG   r   r   r   r   tupler~   	enumeratelocal_related_fieldsr   r   )r"   r#   r$   r   
related_pkindexr   s   &f&    r%   r&   !ReverseOneToOneDescriptor.__set__  s   " = ll33Hd3KG" 00: !3!3!8!8$? # E<<#=#=>> NN..LL..LL..44@@  !!)%+%8%8&&&" ||&"("5"5OOh# ((99  "'( 
  !\\//FF !\\//FF J !*$,,*<*<*Q*Q R}}j.?@ !S
 LL))(E:
 LL//x@r(   c                f    \         V P                  P                  V P                  P                  33# r   )r   r   rP   re   rf   s   &r%   r   $ReverseOneToOneDescriptor.__reduce__X  s&    ++T\\->->???r(   r   r   )r*   r+   r,   r-   r   r[   r   r_   r   rs   r   r   r&   r   r.   r/   r0   s   @r%   r   r     sN     

 
 
 0V
@*XGAR@ @r(   r   c                   P   a  ] tR tRt o RtR t]R 4       tR
R ltR t	R t
R	tV tR# )ReverseManyToOneDescriptori]  a  
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_reverse_many_to_one_manager()`` defined below.
c                4    Wn         VP                  V n        R # r   )relr   )r"   r   s   &&r%   r[   #ReverseManyToOneDescriptor.__init__m  s    YY
r(   c                    V P                   P                  p\        VP                  P                  V P                   4      # r   )r   r   "create_reverse_many_to_one_manager_default_managerr   r"   r   s   & r%   related_manager_cls.ReverseManyToOneDescriptor.related_manager_clsq  s4    ..1**44HH
 	
r(   Nc                0    Vf   V # V P                  V4      # )a	  
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   )r"   r#   r   s   &&&r%   r   "ReverseManyToOneDescriptor.__get__z  s      K''11r(   c                2    R V P                   P                  3# )zreverse side of a related set)r   r   rf   s   &r%   _get_set_deprecation_msg_params:ReverseManyToOneDescriptor._get_set_deprecation_msg_params  s    +HH""
 	
r(   c                B    \        R V P                  4       ,          4      h)z@Direct assignment to the %s is prohibited. Use %s.set() instead.)	TypeErrorr  r!   s   &&&r%   r&   "ReverseManyToOneDescriptor.__set__  s#    N2245
 	
r(   )r   r   r   )r*   r+   r,   r-   r   r[   r   r   r   r  r&   r.   r/   r0   s   @r%   r   r   ]  s7      
 
2

 
r(   r   c                2   aa  ! VV3R lRV \         4      o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                   :  <a a ] tR tRt oV V3R ltV3R ltRtR tR tR t	V 3R lt
RV 3R	 lltR
R/R ltR]n        R
R/R ltR]n        VV 3R ltR]n        R tR]n        VV 3R ltR]n        R tR]n        VV 3R ltR]n        R tR]n         ZP*                  P,                  '       dC   R
R/R ltR]n        R
R/R ltR]n        R
R/R ltR]n        R
R/R ltR]n        R tR]n        R
RRR/R ltR]n        R
RRR/R ltR]n        RtVtV ;t # ):create_reverse_many_to_one_manager.<locals>.RelatedManageri  c                   < \         SV `  4        Wn        SP                  V n        SP
                  V n        V P
                  P                  V/V n        R # r   )r   r[   r#   r   rP   r   re   core_filters)r"   r#   r   r   s   &&r%   r[   Ccreate_reverse_many_to_one_manager.<locals>.RelatedManager.__init__  s@    G$M**DJDJ!%( ;Dr(   c                  < \        V P                  V4      p\        VP                  S4      pV! V P                  4      # r   )r   rP   r   r   r#   )r"   managermanager_classr   s   &$ r%   __call__Ccreate_reverse_many_to_one_manager.<locals>.RelatedManager.__call__  s5    djj'2G>w?P?PRUVM //r(   Tc                    V P                   P                   FL  p\        V P                  VP                  4      e   K'  \        RV P                  : RVP                   R24      h	  R # )N"#" needs to have a value for field "z'" before this relationship can be used.)r   r~   r   r#   r   rz   )r"   r   s   & r%   _check_fk_valHcreate_reverse_many_to_one_manager.<locals>.RelatedManager._check_fk_val  s[    ::4==%--8@$DMM, -!MM?*QS  ;r(   c           
     4   V P                   ;'       g-    \        P                  ! V P                  V P                  R7      p\
        V,          P                  P                  pVP                  V P                  R7       V P                   '       d   VP                  V P                   4      pRVn
        VP                  ! R/ V P                  B pV P                  P                   FJ  p\        V P                  VP                   4      pVe   VR8X  g   K0  V'       g   K:  VP#                  4       u # 	  V P                  P$                  '       dV    V P                  P&                  p\        V P                  VP                   4      pV P                  WpP                  //Vn        V#   \(         dh    \+        T P                  P,                  R,          P.                   Uu. uF#  p\        T P                  TP                   4      NK%  	  Mu upi up4      p Li ; i)@
Filter the queryset for the instance this manager is bound to.
rx   T r)   )r8   r   db_for_readrP   r#   r   r;   !interprets_empty_strings_as_nullsr{   r4   _defer_next_filterr   r  r   r~   r   r   nonemany_to_onetarget_fieldr   r   
path_infostarget_fields_known_related_objects)r"   rC   rG   empty_strings_as_nullr   valr!  
rel_obj_ids   &&      r%   _apply_rel_filtersMcreate_reverse_many_to_one_manager.<locals>.RelatedManager._apply_rel_filters  s    SSV//

T]]SB$/%h88 " 7xxx#>>$((3*.H';):):;H::dmmU]];;3"91F1F#==?* ; zz%%%
N#'::#:#:L ")8L8L!MJJJ]] ;3/ O "  "' 15

0E0Eb0I0W0W0W $DMM<3G3GH0W"Js   F% %9H)H
HHc                     V P                   P                  P                  V P                  P                  P
                  4       R #   \        \        3 d     R # i ; ir   )r#   _prefetched_objects_cachepopr   rb   r   rd   r   rf   s   &r%   _remove_prefetched_objectsUcreate_reverse_many_to_one_manager.<locals>.RelatedManager._remove_prefetched_objects  sK    77;;JJ++66 #H- s   AA AAc                  < V P                   P                  4       '       g.   \        V P                   P                  P                  : R 24      h V P                   P
                  V P                  P                  P                  ,          #   \        \        3 d#    \        ST `1  4       pT P                  T4      u # i ; i)zQ instance needs to have a primary key value before this relationship can be used.)r#   r   rz   r   r*   r+  r   rb   r   rd   r   r   rs   r(  )r"   rC   r   s   & r%   rs   Gcreate_reverse_many_to_one_manager.<locals>.RelatedManager.get_queryset  s     ==++-- }}..77: ;N O 9}}>>JJ++66  #H- 9 7/1..x889s   :B 0B>=B>c                  < V'       d   \        V4      ^8w  d   \        R4      hV'       d
   V^ ,          M\        SV `  4       pVP	                  V^ ,          R7       TP                  VP                  ;'       g    V P                  4      pV P                  P                  pV P                  P                  pV Uu/ uF  qe! V4      VbK  	  pp\        W0P                  P                  V4      pV FO  pV P                  P                  V4      '       d   K&  Wt! V4      ,          p	V P                  P                  W4       KQ  	  V P                  P                  P                  p
W4VRV
R3# u upi )rv   rw   rx   F)ry   rz   r   rs   r{   r4   r8   r   r}   r|   rK   re   r   r   rb   r   )r"   rE   r   rC   r   r   r   r   r   r#   r   r   s   &&&        r%   r   Qcreate_reverse_many_to_one_manager.<locals>.RelatedManager.get_prefetch_querysets  s-   S^q0 #  (1y|eg6J6LH16~~hll&>&>dhh?H::==L JJ@@MDMNIDmD147INN0::??IVH $zz++G44-l7.CDHJJ//B $ 00;;J=%URR Os   <E+bulkc               4  a  S P                  4        S P                  4        \        P                  ! S P                  S P
                  R 7      pV 3R lpV'       d   . pV Fo  pV! V4       VP                  P                  '       g   VP                  P                  V8w  d   \        RV,          4      hVP                  VP                  4       Kq  	  S P                  P                  P                  V4      P                  VR7      P                  ! R/ S P                   P"                  S P
                  /B  R# \$        P&                  ! VRR7      ;_uu_ 4        V F  pV! V4       VP)                  4        K  	  RRR4       R#   + '       g   i     R# ; i)rx   c                    < \        V SP                  4      '       g2   \        R SP                  P                  P                  : RV : 24      h\        V SP                  P                  SP                  4       R# )'' instance expected, got N)	r   rP   r  rM   r   r   r   re   r#   )r   r"   s   &r%   check_and_update_obj\create_reverse_many_to_one_manager.<locals>.RelatedManager.add.<locals>.check_and_update_obj  sX    !#tzz22# !JJ,,88  TZZ__dmm<r(   zA%r instance isn't saved. Use bulk=False or save the object first.pk__inFr4   	savepointNr)   )r  r-  r   r   rP   r#   r   r   rG   rz   appendr   ro   r4   r   updater   re   r   atomicsave)r"   r3  objsrG   r8  pksr   s   f$*    r%   add>create_reverse_many_to_one_manager.<locals>.RelatedManager.add  s/    ++-$$TZZ$--HB	= C(-zz(((CJJMMR,?(0256  JJsvv&   

((..r2999ELL 

 !''bEBB#,S1
  $ CBBBs   "FF	c               T   "   \        V P                  4      ! VR V/ G Rj  xL
 #  L5ir3  Nr   rD  r"   r3  rB  s   &$*r%   aadd?create_reverse_many_to_one_manager.<locals>.RelatedManager.aadd7  s$     &txx0$BTBBBB   (&(c                  < V P                  4        V P                  4        V P                  WP                  P                  &   \
        P                  ! V P                  V P                  R 7      p\        SV P                  V4      `*  ! R/ VB # rx   r)   )r  r-  r#   r   re   r   r   rP   r   rp   creater"   r   rG   RelatedManagerr   s   &, r%   rO  Acreate_reverse_many_to_one_manager.<locals>.RelatedManager.create<  sg     ++-&*mmF::??#$$TZZ$--HB)<DNvNNr(   c                T   "   \        V P                  4      ! R/ VB G R j  xL
 #  L5iNr)   r   rO  r"   r   s   &,r%   acreateBcreate_reverse_many_to_one_manager.<locals>.RelatedManager.acreateE  s"     &t{{3=f====rL  c                   < V P                  4        V P                  WP                  P                  &   \        P
                  ! V P                  V P                  R 7      p\        SV P                  V4      `&  ! R/ VB # rN  )
r  r#   r   re   r   r   rP   r   rp   get_or_createrP  s   &, r%   rZ  Hcreate_reverse_many_to_one_manager.<locals>.RelatedManager.get_or_createJ  s[     &*mmF::??#$$TZZ$--HB)<KUfUUr(   c                T   "   \        V P                  4      ! R/ VB G R j  xL
 #  L5irT  r   rZ  rV  s   &,r%   aget_or_createIcreate_reverse_many_to_one_manager.<locals>.RelatedManager.aget_or_createR  s$     &t'9'9:DVDDDDrL  c                   < V P                  4        V P                  WP                  P                  &   \        P
                  ! V P                  V P                  R 7      p\        SV P                  V4      `&  ! R/ VB # rN  )
r  r#   r   re   r   r   rP   r   rp   update_or_createrP  s   &, r%   ra  Kcreate_reverse_many_to_one_manager.<locals>.RelatedManager.update_or_createW  s\     &*mmF::??#$$TZZ$--HB)<NXQWXXr(   c                T   "   \        V P                  4      ! R/ VB G R j  xL
 #  L5irT  r   ra  rV  s   &,r%   aupdate_or_createLcreate_reverse_many_to_one_manager.<locals>.RelatedManager.aupdate_or_create_  s$     &t'<'<=GGGGGrL  c               ~   V'       g   R # V P                  4        V P                  P                  V P                  4      p\	        4       pV F  p\        WPP                  4      '       g2   \        RV P                  P                  P                  : RV: 24      hV P                  P                  V4      V8X  d   VP                  VP                  4       K  V P                  P                  P                  P                  V: RV P                  : R24      h	  V P                  V P!                  VR7      V4       R # )Nr6  r7  z is not related to r`   r:  )r  r   r|   r#   setr   rP   r  rM   r   r}   rD  r   rb   rc   _clearr   )r"   r3  rB  r&  old_idsr   s   &$*   r%   removeAcreate_reverse_many_to_one_manager.<locals>.RelatedManager.removeh  s    ""$jj::4==I%C%c::66' !%

 0 0 < < #  zz99#>#ECFF+"jj55;;HH:=t}}M     DKKwK7>r(   c               T   "   \        V P                  4      ! VR V/ G Rj  xL
 #  L5irG  r   rk  rI  s   &$*r%   aremoveBcreate_reverse_many_to_one_manager.<locals>.RelatedManager.aremove  s$     *4;;7IDIIIIrL  c               H    V P                  4        V P                  W4       R # r   )r  ri  r"   r3  s   &$r%   clear@create_reverse_many_to_one_manager.<locals>.RelatedManager.clear  s    ""$D'r(   c               V   "   \        V P                  4      ! VR 7      G Rj  xL
 #  L5i)r3  Nr   rs  rr  s   &$r%   aclearAcreate_reverse_many_to_one_manager.<locals>.RelatedManager.aclear  s     *4::6DAAAAs    )')c                   V P                  4        \        P                  ! V P                  V P                  R 7      pVP                  V4      pV'       d+   VP                  ! R/ V P                  P                  R/B  R# \        P                  ! VRR7      ;_uu_ 4        V FJ  p\        W@P                  P                  R4       VP                  V P                  P                  .R7       KL  	  RRR4       R#   + '       g   i     R# ; i)rx   NFr<  )update_fieldsr)   )r-  r   r   rP   r#   r4   r?  r   re   r   r@  r   rA  )r"   rC   r3  rG   r   s   &&&  r%   ri  Acreate_reverse_many_to_one_manager.<locals>.RelatedManager._clear  s    //1((dmmL#>>"-OO>tzz&=>$++"FF#+C#C$?HHDJJOO3DHE $, GFFFs    AC;;D	rs  Fc                  V P                  4        \        V4      pV P                  P                  '       Ed   \        P
                  ! V P                  V P                  R 7      p\        P                  ! VRR7      ;_uu_ 4        V'       d&   V P                  VR7       V P                  ! VRV/  M\        V P                  V4      P                  4       4      p. pV F-  pWu9   d   VP                  V4       K  VP!                  V4       K/  	  V P                  ! VRV/  V P                  ! VRV/  RRR4       R# V P                  ! VRV/  R#   + '       g   i     R# ; i)rx   Fr<  rv  r3  N)r  r   r   r   r   r   rP   r#   r   r@  rs  rD  rh  r4   rq   rk  r>  )r"   rB  r3  rs  rG   old_objsnew_objsr   s   &&$$    r%   rh  >create_reverse_many_to_one_manager.<locals>.RelatedManager.set  s	     ;Dzz((dmmL ''bEBB


-$2T2#&tzz"~'9'9';#<#%#'C" ( 4 ( 4	 $( X9D9(66 CB  $*T*! CBBs   B/EE#	c               X   "   \        V P                  4      ! WVR 7      G Rj  xL
 #  L5i))rB  r3  rs  Nr   rh  )r"   rB  r3  rs  s   &&$$r%   aset?create_reverse_many_to_one_manager.<locals>.RelatedManager.aset  s!     &txx0dUSSSS   !*(*)r  r   r#   rP   r   )!r*   r+   r,   r-   r[   r  do_not_call_in_templatesr  r(  r-  rs   r   rD  alters_datarJ  rO  rW  rZ  r^  ra  re  r   r   rk  ro  rs  rx  ri  rh  r  r.   r/   r   )r   r1   rQ  r   s   @@r%   rQ  r
    s{    	<	0
 $( 	&	P		9"	S0#	#$ #	#J 	C 	C  	O "	> #	V %)!	E &*"	Y (,$	H )-% 99>>>? ?0 "&FJ J #'G(D ( !%EB4 B "&FF "&F	+D 	+ 	+4 	T4 	Tu 	T  r(   rQ  r   )
superclassr   rQ  s   &f@r%   r   r     s"    b  b Z b H	 r(   c                   `   a a ] tR tRt oRtRV 3R llt]R 4       t]R 4       t	R t
RtVtV ;t# )	ManyToManyDescriptori  a  
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.
c                2   < \         SV `  V4       W n        R # r   )r   r[   reverse)r"   r   r  r   s   &&&r%   r[   ManyToManyDescriptor.__init__  s    r(   c                .    V P                   P                  # r   )r   throughrf   s   &r%   r  ManyToManyDescriptor.through  s    
 xxr(   c                    V P                   '       d   V P                  P                  MV P                  P                  p\	        VP
                  P                  V P                  V P                   R 7      # )r  )r  r   r   rP   #create_forward_many_to_many_managerr   r   r   s   & r%   r   (ManyToManyDescriptor.related_manager_cls  sM    26,,,..DHHNN2**44HHLL
 	
r(   c                    R V P                   '       d   RMR,          V P                   '       d   V P                  P                  3# V P                  P                  3# )z%s side of a many-to-many setr  forward)r  r   r   r   re   rf   s   &r%   r  4ManyToManyDescriptor._get_set_deprecation_msg_params  sM    + LLLyi9&*lllDHH""
 	
 9=


 	
r(   r  )F)r*   r+   r,   r-   r   r[   propertyr  r   r   r  r.   r/   r   r   s   @@r%   r  r    sA      
     
 

 
r(   r  c                :   a aaa  ! VVVV 3R lRS \         4      o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                   t  <a a ] tR tRt oR&V VV3R lltVV3R ltRtR tR tV3R lt	V3R	 lt
V 3R
 ltR&V 3R llt]R 4       tV V3R ltV V3R ltRR/R ltR]n        RR/R ltR]n        R tR]n        R tR]n        V 3R ltR]n        R tR]n        RRRR/R ltR]n        RRRR/R ltR]n        RR/VV 3R lltR]n        RR/R ltR]n        RR/VV 3R lltR]n        RR/R ltR]n        RR/VV 3R lltR]n        RR/R ltR]n        R  t R! t!R" t"RR/R# lt#V 3R$ lt$R%t%Vt&V ;t'# )'?create_forward_many_to_many_manager.<locals>.ManyRelatedManageri  Nc                  < \         SV `  4        Wn        S'       g   SP                  V n        SP                  P                  4       V n        SP                  P                  V n        SP                  P                  4       V n
        SP                  P                  4       V n        SP                  V n        MSP                  V n        SP                  P                  V n        SP                  P                  4       V n        SP                  P                  4       V n
        SP                  P                  4       V n        R V n        SP                  V n        SV n        V P                  P"                  P%                  V P                  4      V n        V P                  P"                  P%                  V P                  4      V n        / V n        / V n        V P&                  P.                   Fg  w  r#V P                  : RVP                  : 2p\1        WP2                  4      V P*                  V&   VP                  V P,                  VP                  &   Ki  	  V P&                  P5                  V4      V n        RV P6                  9   d0   \9        RV: RV P,                  V P                  ,          : R24      hVP;                  4       '       g'   \9        RVP<                  P>                  ,          4      hR# )F__Nr  r  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[   r#   rP   r   related_query_namequery_field_namere   prefetch_cache_namem2m_field_namesource_field_namem2m_reverse_field_nametarget_field_namesymmetricalr   r  r  rM   	get_fieldsource_fieldr!  r  pk_field_namesr   r   r   r|   related_valrz   r   r   r*   )r"   r#   r   r   core_filter_keyr   r   r  s   &&   r%   r[   Hcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.__init__  s<   G$M YY
(+		(D(D(F%+.99>>(),)A)A)C&),)I)I)K&#&??  ..
(+		%+.99+G+G+I(),)I)I)K&),)A)A)C&#( ;;DL"DL $ 2 2 < <T=S=S TD $ 2 2 < <T=S=S TD "D"$D&*&7&7&F&F".2.C.CX]]"S5<XGWGW5X!!/25=]]##HMM2 'G
  $00JJ8TDt'''   !4!4T5K5K!L!LN  &&(( ?((112  )r(   c                  < \        V P                  V4      p\        VP                  SS4      pV! V P                  R 7      # r   )r   rP   r  r   r#   )r"   r  r  r   r  s   &$ r%   r  Hcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.__call__/  s;    djj'2G?!!3M !$--88r(   Tc                   \         P                  ! V P                  V P                  3.4      p\	        V\
        4      '       * ;'       g    VP                  4       pV'       d.   V\         P                  ! V P                   R 2V3.4      ,          pV P                  '       dk   \         P                  ! V P                  V P                  3.4      pV'       d.   V\         P                  ! V P                   R 2V3.4      ,          pW$,          pV# )r3   )	r
   rO  r  r  r   r   _has_filtersr  r  )r"   removed_valsfiltersremoved_vals_filterssymmetrical_filterss   &&   r%   _build_remove_filtersUcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager._build_remove_filters8  s    hh!7!79I9I JKLG |X66UU,:S:S:U ! $188)?)?(@&E|%T$UVV&'hh,,d.>.>?@'# ('188!334D9<HI, ' .Nr(   c                    VP                  V P                  R7       V P                  '       d   VP                  V P                  4      pRVn        VP                  4       P                  ! R/ V P                  B # )r  rx   Tr)   )r{   r#   r8   r4   r  _next_is_stickyr   r  )r"   rC   s   &&r%   r(  Rcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager._apply_rel_filtersL  s_     7xxx#>>$((3*.H'++-44It7H7HIIr(   c                   < \        SP                  P                  V P                  4       F#  w  r VP                  V P
                  ,          u # 	  R #   \        \        3 d     K=  i ; ir   )rU   r   rP   r#   r+  r  rd   r   r"   r#   rI   r   s   &  r%   get_prefetch_cacheRcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.get_prefetch_cacheV  s_      3399??DMMR#==d>V>VWW  S
  '1 s   AA*)A*c                   < \        SP                  P                  V P                  4       F+  w  r VP                  P                  V P                  4       K-  	  R #   \        \        3 d     KE  i ; ir   )	rU   r   rP   r#   r+  r,  r  rd   r   r  s   &  r%   r-  Zcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager._remove_prefetched_objects`  s]      3399??DMMR66::4;S;ST  S '1 s   %AA21A2c                n   < V P                  4       ;pe   V# \        SV `	  4       pV P                  V4      # r   )r  r   rs   r(  )r"   cacherC   r   s   &  r%   rs   Lcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.get_queryseti  s:    0022? 7/1..x88r(   c                8  <aa V'       d   \        V4      ^8w  d   \        R4      hV'       d
   V^ ,          M\        S	V `  4       pVP	                  V^ ,          R7       TP                  VP                  ;'       g    V P                  4      p\        W0P                  V4      pV P                  P                  P                  V P                  4      oSP                  P                  P                  p\        VP                   ,          oSP"                  P$                  pTP'                  SP(                   Uu/ uF4  pRVP*                  ,          V! V4      : RV! VP,                  4      : 2bK6  	  upR7      pVVV3R lVV3R lRV P.                  R3# u upi )	rv   rw   rx   z_prefetch_related_val_%sr`   )selectc                    <a  \         ;QJ d"    . VV 3R  lSP                   4       F  NK  	  5# ! VV 3R  lSP                   4       4      # )c              3   v   <"   T F.  pVP                  \        SR VP                   24      S4      x  K0  	  R# 5i)_prefetch_related_val_Nget_db_prep_valuer   r   )r   f
connectionresults   & r%   r   {create_forward_many_to_many_manager.<locals>.ManyRelatedManager.get_prefetch_querysets.<locals>.<lambda>.<locals>.<genexpr>  sE      %
 5	 ''*@(LM"  5s   69)r   r   )r  r  fks   fr%   <lambda>hcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.get_prefetch_querysets.<locals>.<lambda>  s?    uu %
  44%u  u %
  44%  r(   c                    <a  \         ;QJ d"    . VV 3R  lSP                   4       F  NK  	  5# ! VV 3R  lSP                   4       4      # )c              3   p   <"   T F+  pVP                  \        SVP                  4      S4      x  K-  	  R # 5ir   r  )r   r  r  r   s   & r%   r   r    s3      #6 ''aii(@*MM6s   36)r   r~   )r   r  r  s   fr%   r  r    s;    UU #66#U U #66# r(   F)ry   rz   r   rs   r{   r4   r8   rK   r  r  rM   r  r  rP   r   r   rG   ops
quote_nameextrar   r   columnr  )
r"   rE   r   rC   
join_tableqnr  r  r  r   s
   &&&    @@r%   r   Vcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.get_prefetch_querysetsp  sd   S^q0 #  (1y|eg6J6LH16~~hll&>&>dhh?H0//H ##--d.D.DEB00J$X[[1J**B~~
  44	 5 /ii *~r!((|"55 5	 & H  (( s   9:Fc                   V P                   P                  '       g   R # \        P                  ! V P                  V P
                  R7      p\        V,          P                  P                  '       g   R # RV P
                  /pV P                  P                  P                  WR7      pV P                  V P                  ^ ,          /pV P                   P                  '       d   RVRV P                  ,          &   VP                  ! R/ VB # )Nrx   r#   rm   Fz
%s__isnullr)   )r!  db_constraintr   r  r  r#   r   r;   supports_foreign_keysro   rp   r  r  r   r  r   )r"   rG   rn   r  r  s   &    r%   constrained_targetRcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.constrained_target  s    
 $$222##DLL4==IBr?++AAA/Ell00;;B;LG--t/?/?/BCG   %%%AFt'='==>>>,G,,r(   c                   < S\         J d3   V P                  4       f!   V P                  ;pe   VP                  4       # \        SV `  4       # r   )r	   r  r  existsr   r"   r  r   r  s   & r%   r  Fcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.exists  sH    g%++-5+/+B+BB'O)0022w~''r(   c                   < S\         J d3   V P                  4       f!   V P                  ;pe   VP                  4       # \        SV `  4       # r   )r	   r  r  countr   r  s   & r%   r  Ecreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.count  sG    g%++-5+/+B+BB'O)//11w}&r(   through_defaultsc                  V P                  4        \        P                  ! V P                  V P                  R 7      p\
        P                  ! VRR7      ;_uu_ 4        V P                  ! V P                  V P                  .VO5RV/  V P                  '       d,   V P                  ! V P                  V P                  .VO5RV/  RRR4       R#   + '       g   i     R# ; i)rx   Fr<  r  N)r-  r   r   r  r#   r   r@  
_add_itemsr  r  r  )r"   r  rB  rG   s   &$* r%   rD  Ccreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.add  s    ++-$$T\\DMMJB##">>****  &6	 ###OO....  *:	 ?>>>s   A)CC!	c               T   "   \        V P                  4      ! VR V/ G Rj  xL
 #  L5i)r  NrH  )r"   r  rB  s   &$*r%   rJ  Dcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.aadd  s0     &txx0(8   rL  c                x    V P                  4        V P                  ! V P                  V P                  .VO5!   R # r   )r-  _remove_itemsr  r  r"   rB  s   &*r%   rk  Fcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.remove  s0    ++-t55t7M7MUPTUr(   c                P   "   \        V P                  4      ! V!  G R j  xL
 #  L5ir   rn  r  s   &*r%   ro  Gcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.aremove  s     &t{{3T::::s   &$&c                  < \         P                  ! V P                  V P                  R 7      p\        P
                  ! VRR7      ;_uu_ 4        \        P                  P                  V P                  RV P                  V P                  V P                  RVR7       V P                  4        V P                  \        SV `9  4       P                  V4      4      pV P                  P                   P                  V4      P#                  V4      P%                  4        \        P                  P                  V P                  RV P                  V P                  V P                  RVR7       RRR4       R#   + '       g   i     R# ; i)rx   Fr<  	pre_clearNsenderactionr#   r  rP   pk_setr4   
post_clear)r   r   r  r#   r   r@  r   m2m_changedsendr  rP   r-  r  r   rs   r4   r   r   delete)r"   rG   r  r   s   &  r%   rs  Ecreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.clear  s   $$T\\DMMJB##">>##((<<&!]] LL** )  //144UW5I5K5Q5QRT5UV--33B7>>wGNNP##((<<'!]] LL** )  ?>>>s   DE33F	c                R   "   \        V P                  4      ! 4       G R j  xL
 #  L5ir   rw  rf   s   &r%   rx  Fcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.aclear  s     &tzz24444s   '%'rs  Fc          	     4   \        V4      p\        P                  ! V P                  V P                  R 7      p\
        P                  ! VRR7      ;_uu_ 4        V'       d$   V P                  4        V P                  ! VRV/  M\        V P                  V4      P                  V P                  P                  P                  RR7      4      p. pV F  p\        WpP                  4      '       d#   V P                  P!                  V4      ^ ,          MV P                  P#                  V4      pW9   d   VP%                  V4       Kt  VP'                  V4       K  	  V P$                  ! V!   V P                  ! VRV/  RRR4       R#   + '       g   i     R# ; i)rx   Fr<  r  TflatN)r   r   r   r  r#   r   r@  rs  rD  rh  r4   values_listr!  r   r   rP   r|   get_prep_valuerk  r>  )	r"   rB  rs  r  rG   rj  r  r   fk_vals	   &&$$     r%   rh  Ccreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.set  s9    ;D$$T\\DMMJB##">>JJLHHdF5EF!

222 --::BB 3 G  "H#  *#zz:: !--GGLQO!%!2!2!A!A#!F 
 ",#NN62$OOC0  $ KK)HHhJ9IJ1 ?>>>s   D$FF	c               X   "   \        V P                  4      ! WVR 7      G Rj  xL
 #  L5i))rB  rs  r  Nr  )r"   rB  rs  r  s   &&$$r%   r  Dcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.aset4  s+     &txx09I   r  c                  < \         P                  ! V P                  P                  V P                  R 7      p\        SV P                  V4      `  ! R/ VB pV P                  WAR7       V# rx   )r  r)   )r   r   r#   r   r   rp   rO  rD  )r"   r  r   rG   new_objManyRelatedManagerr   s   &$,  r%   rO  Fcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.create;  sT    $$T]]%<%<t}}UB.0CKUfUGHHWH@Nr(   c               X   "   \        V P                  4      ! RR V/VB G Rj  xL
 #  L5ir  Nr)   rU  r"   r  r   s   &$,r%   rW  Gcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.acreateC  s5     &t{{3 !15;   r  c                  < \         P                  ! V P                  P                  V P                  R 7      p\        SV P                  V4      `  ! R/ VB w  rEV'       d   V P                  WAR7       WE3# r	  )r   r   r#   r   r   rp   rZ  rD  r"   r  r   rG   r   createdr  r   s   &$,   r%   rZ  Mcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.get_or_createJ  sc    $$T]]%<%<t}}UB !3T__R5HW LC
 @<r(   c               X   "   \        V P                  4      ! RR V/VB G Rj  xL
 #  L5ir  r]  r  s   &$,r%   r^  Ncreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.aget_or_createW  s7     &t'9'9: !15;   r  c                  < \         P                  ! V P                  P                  V P                  R 7      p\        SV P                  V4      `   ! R/ VB w  rEV'       d   V P                  WAR7       WE3# r	  )r   r   r#   r   r   rp   ra  rD  r  s   &$,   r%   ra  Pcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.update_or_create^  sm    $$T]]%<%<t}}UB "DOOB$7 )!')LC
 @<r(   c               X   "   \        V P                  4      ! RR V/VB G Rj  xL
 #  L5ir  rd  r  s   &$,r%   re  Qcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager.aupdate_or_createk  s7     &t'<'<= !15;   r  c           
        ^ RI Hp \        4       pV P                  P                  P                  V4      pV EF4  p\        W`P                  4      '       d   \        P                  ! W`P                  4      '       gK   \        RV: RV P                  P                  P                  : RVP                  P                  : R24      hVP                  V4      ^ ,          pVf   \        RV: RV: R24      hVP                  V4       K  \        Wc4      '       d2   \!        RV P                  P                  P"                  : R	V: 24      hVP                  VP%                  V4      4       EK7  	  V# )
zC
Return the set of ids of `objs` that the target field references.
)ModelzCannot add "z": instance is on database "z", value is on database "r  z": the value for field "z	" is Noner6  r7  )django.db.modelsr  rh  r  rM   r  r   rP   r   r   r#   rz   r   rG   r|   rD  r  r   r  )r"   r  rB  r  
target_idsr!  r   	target_ids   &&&     r%   _get_target_idsOcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager._get_target_idsr  s!    /J<<--778IJLc::..!00mmDD(  #DMM$8$8$;$;SZZ]]L 
 !- F Fs KA NI (("$57  NN9-++#::++77> 
 NN<#>#>s#CD+ , r(   c                    V P                   P                  P                  V4      P                  VRR7      P                  ! R/ WP
                  ^ ,          RV,          V/B pVP                  V4      # )zW
Return the subset of ids of `objs` that aren't already assigned to
this relationship.
Tr   r   r)   )r  r   r4   r  r   r  
difference)r"   r  r  rG   r  valss   &&&&& r%   _get_missing_target_idsWcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager._get_missing_target_ids  sw     --33B7.T:  *+;+;A+> #44j  ((..r(   c                f   V P                   P                  P                  RJ;'       d"    \        V,          P                  P
                  pV P                  ;'       g    W P                  8H  ;'       d*    \        P                  P                  V P                   4      pTTT;'       d    V'       * 3# )a/  
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)r  rM   auto_createdr   r;   supports_ignore_conflictsr  r  r   r  has_listeners)r"   rG   r  can_ignore_conflictsmust_send_signalss   &&&  r%   _get_add_planMcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager._get_add_plan  s     ""//u< G GO,,FF ! KK 15K5K K!D !D&&44T\\B  %!%??.?*? r(   c                  V'       g   R # \        \        T;'       g    / 4      4      pV P                  W$4      p\        P                  ! V P
                  V P                  R7      pV P                  Wa4      w  rxp	V	'       d|   V P
                  P                  P                  V4      P                  V U
u. uF8  p
V P
                  ! R
/ RV,          V P                  ^ ,          RV,          V
/B NK:  	  up
RR7       R # V P                  WWe4      p\        P                  ! VRR7      ;_uu_ 4        V'       dO   \        P                   P#                  V P
                  RV P                  V P$                  V P&                  VVR7       V P
                  P                  P                  V4      P                  V U
u. uF:  p
V P
                  ! R
/ VBRV,          V P                  ^ ,          RV,          V
/B NK<  	  up
VR7       V'       dO   \        P                   P#                  V P
                  R	V P                  V P$                  V P&                  VVR7       R R R 4       R # u up
i u up
i   + '       g   i     R # ; i)Nrx   z%s_idT)ignore_conflictsFr<  pre_addr  post_addr)   )dictr   r   r   r   r  r#   r-  r   r4   bulk_creater  r%  r   r@  r   r  r  r  rP   )r"   r  r  r  rB  r  rG   r+  r,  can_fast_addr  missing_target_idss   &&&$*       r%   r  Jcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager._add_items  sR    #$56F6L6L"$MN--.?FJ$$T\\DMMJBDHDVDVEA \ --33B7CC *4 *4I   '*; ;T=M=Ma=P '*; ;Y *4 &* D  !%!=!=!b" ##">>$'',,#||(!% $"jj1  -  --33B7CC *<	 *<I  . !(*; ;T=M=Ma=P '*; ;Y *<	 &: D  %'',,#||)!% $"jj1  - 7 ?>!:	 ?>>s-   4>I!/B	I+8A I&8I+	AI+&I++I<	c                  < V'       g   R # \        4       pV Fd  p\        WPP                  4      '       d6   V P                  P	                  V4      ^ ,          pVP                  V4       KS  VP                  V4       Kf  	  \        P                  ! V P                  V P                  R7      p\        P                  ! VRR7      ;_uu_ 4        \        P                  P                  V P                  RV P                  V P                  V P                  VVR7       \         SV `E  4       pVP%                  4       '       dJ   VP'                  V4      P(                  ! R/ RV P                  P                  P*                  ,          V/B p	MTp	V P-                  V	4      p
V P                  P.                  P'                  V4      P)                  V
4      P1                  4        \        P                  P                  V P                  RV P                  V P                  V P                  VVR7       R R R 4       R #   + '       g   i     R # ; i)	Nrx   Fr<  
pre_remover  r   post_remover)   )rh  r   rP   r!  r|   rD  r   r   r  r#   r   r@  r   r  r  r  r   rs   r  r4   r   r   r  r   r  )r"   r  r  rB  rj  r   r  rG   target_model_qsold_valsr  r   s   &&&*       r%   r  Mcreate_forward_many_to_many_manager.<locals>.ManyRelatedManager._remove_items  s   
  eGc::..!..HHMaPFKK'KK$  $$T\\DMMJB##">>##((<<'!]] LL**" )  #('"6"8"//11.44R8??  #d&7&7&D&D&L&LLgV H  'H44X>--33B7>>wGNNP##((<<(!]] LL**" ) + ?>>>s   EH55I	)r  r#   rP   r  r  r  r  r  r  r  r  r!  r  r  r   )(r*   r+   r,   r-   r[   r  r  r  r(  r  r-  rs   r   r  r  r  r  rD  r  rJ  rk  ro  rs  rx  rh  r  rO  rW  rZ  r^  ra  re  r   r%  r-  r  r  r.   r/   r   )r   r1   r  r   r  r  s   @@r%   r  r    s    0	 0	d	9 $( 	(	J			90	d 
	- 
	-$	(	'	d 	( 	T 	
  	V "	; #	4 !	5 "	KU 	KT 	K@ 	E 	D 	
  	T 	 	 "	D 	
 #		 D 		  		  %)!	4 	
 &*"		 t 		  		  (,$	d 	
 )-%	@	/&	BE	PTE	N/	 /	r(   r  r  )r  r   r  r  s   fff@r%   r  r    s"    @	 @	Z @	D r(   N),r   asgiref.syncr   django.core.exceptionsr   	django.dbr   r   r   r   r   r  r	   r
   r   r   django.db.models.expressionsr   %django.db.models.fields.tuple_lookupsr   django.db.models.functionsr   django.db.models.lookupsr   r   django.db.models.queryr   django.db.models.query_utilsr   django.db.models.utilsr   r   django.utils.functionalr   r   rK   rU   rW   r   r   r   r   r  r  r)   r(   r%   <module>rI     s   ?B ' -  9 8 1 9 0 A + : @ 36"3 60	$_< _<D1@ : 1@h@@ @@F6
 6
rl^	,
5 ,
^J	r(   