
    (ph&2                         S r SSKrSSKJr  SSKJr  SSKJr  SSKJ	r	  SSK
Jr  SS	KJr   " S
 S\5      r " S S\5      r " S S\5      r " S S\5      rg)al  
"Rel objects" for related fields.

"Rel objects" (for lack of a better name) carry information about the relation
modeled by a related field and provide some utility functions. They're stored
in the ``remote_field`` attribute of the field.

They also act as reverse fields for the purposes of the Meta API because
they're the closest concept currently available.
    N)
exceptions)RemovedInDjango60Warning)cached_property)make_hashable   )BLANK_CHOICE_DASH)FieldCacheMixinc                   ~   \ rS rSrSrSrSrSrSrSr	Sr
     S&S jr\S 5       r\S 5       r\S	 5       r\S
 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       rS rS rS rS r\S 5       rS r\S 5       rS rS rS r S\!SS4S jr"S r#S r$S r%S r&S  r'S'S! jr(S'S" jr)\S# 5       r*S$ r+S%r,g)(ForeignObjectRel   z
Used by ForeignObject to store information about the relation.

``_meta.get_fields()`` returns this class to provide access to the field
flags for the reverse relation.
TFNc                     Xl         X l        X0l        X@l        Uc  0 OUU l        X`l        Xpl        SU l        SU l        g )NFT)	fieldmodelrelated_namerelated_query_namelimit_choices_toparent_link	on_deletesymmetricalmultiple)selfr   tor   r   r   r   r   s           Z/var/www/html/venv/lib/python3.13/site-packages/django/db/models/fields/reverse_related.py__init__ForeignObjectRel.__init__*   sD     

("4&6&>DT&"     c                 "    U R                  5       $ N)	is_hiddenr   s    r   hiddenForeignObjectRel.hiddenC   s    ~~r   c                 6    U R                   R                  5       $ r   )r   r   r    s    r   nameForeignObjectRel.nameG   s    zz,,..r   c                     U R                   $ r   )r   r    s    r   remote_fieldForeignObjectRel.remote_fieldK   s    zzr   c                     U R                   S   R                  n[        U5      S:  a  [        R                  " S5      eUS   $ )zw
When filtering against this relation, return the field on the remote
model against which the filtering should happen.
r   z1Can't use target_field for multicolumn relations.r   )
path_infostarget_fieldslenr   
FieldError)r   r,   s     r   target_fieldForeignObjectRel.target_fieldO   sH     +99}!''C  Qr   c                 z    U R                   R                  (       d  [        S5      eU R                   R                  $ )NzVThis property can't be accessed before self.field.contribute_to_class has been called.)r   r   AttributeErrorr    s    r   related_modelForeignObjectRel.related_model\   s3    zz #  zzr   c                 .    U R                   R                  $ r   )r   many_to_manyr    s    r   r6   ForeignObjectRel.many_to_manye   s    zz&&&r   c                 .    U R                   R                  $ r   )r   one_to_manyr    s    r   many_to_oneForeignObjectRel.many_to_onei       zz%%%r   c                 .    U R                   R                  $ r   )r   r:   r    s    r   r9   ForeignObjectRel.one_to_manym   r<   r   c                 .    U R                   R                  $ r   )r   
one_to_oner    s    r   r@   ForeignObjectRel.one_to_oneq   s    zz$$$r   c                 8    U R                   R                  U5      $ r   )r   
get_lookup)r   lookup_names     r   rC   ForeignObjectRel.get_lookupu   s    zz$$[11r   c                 6    U R                   R                  5       $ r   )r   get_lookupsr    s    r   rG   ForeignObjectRel.get_lookupsx   s    zz%%''r   c                 8    U R                   R                  U5      $ r   )r   get_transform)r   r$   s     r   rJ   ForeignObjectRel.get_transform{   s    zz''--r   c                 6    U R                   R                  5       $ r   )r   get_internal_typer    s    r   rM   "ForeignObjectRel.get_internal_type~   s    zz++--r   c                 .    U R                   R                  $ r   )r   db_typer    s    r   rP   ForeignObjectRel.db_type   s    zz!!!r   c                     S[        U 5      R                  < SU R                  R                  R                  < SU R                  R                  R
                  < S3$ )N<z: .>)type__name__r3   _meta	app_label
model_namer    s    r   __repr__ForeignObjectRel.__repr__   sC    J$$..$$//
 	
r   c           	          U R                   U R                  U R                  U R                  [	        U R
                  5      U R                  U R                  U R                  U R                  4	$ r   )
r   r   r   r   r   r   r   r   r   r   r    s    r   identityForeignObjectRel.identity   s\     JJJJ##$//0NNMM

 
	
r   c                 t    [        XR                  5      (       d  [        $ U R                  UR                  :H  $ r   )
isinstance	__class__NotImplementedr^   )r   others     r   __eq__ForeignObjectRel.__eq__   s*    %00!!}}..r   c                 ,    [        U R                  5      $ r   )hashr^   r    s    r   __hash__ForeignObjectRel.__hash__   s    DMM""r   c                 ^    U R                   R                  5       nUR                  SS 5        U$ )Nr+   )__dict__copypop)r   states     r   __getstate__ForeignObjectRel.__getstate__   s)    ""$ 			,%r    c                    U=(       d    U R                   nU R                  R                  R                  U5      nU(       a  UR                  " U6 nU(       a  UO/ U Vs/ s H  ofR
                  [        U5      4PM     sn-   $ s  snf )z
Return choices with a default blank choices included, for use
as <select> choices for this field.

Analog of django.db.models.fields.Field.get_choices(), provided
initially for utilization by RelatedFieldListFilter.
)r   r3   _default_managercomplex_filterorder_bypkstr)r   include_blankblank_choicer   orderingqsxs          r   get_choicesForeignObjectRel.get_choices   sq     ,Dt/D/D00??@PQh'B -2RT9URTQ44Q.RT9UUU9Us    Bc                 ^    [        U R                  5      =(       a    U R                  S   S:H  $ )z$Should the related object be hidden?r*   +)boolr   r    s    r   r   ForeignObjectRel.is_hidden   s(    D%%&G4+<+<R+@C+GGr   c                 l    [         R                  " S[        5        U R                  R	                  5       $ )NzWForeignObjectRel.get_joining_columns() is deprecated. Use get_joining_fields() instead.)warningswarnr   r   get_reverse_joining_columnsr    s    r   get_joining_columns$ForeignObjectRel.get_joining_columns   s+    ,$	

 zz5577r   c                 6    U R                   R                  5       $ r   )r   get_reverse_joining_fieldsr    s    r   get_joining_fields#ForeignObjectRel.get_joining_fields   s    zz4466r   c                 8    U R                   R                  X!5      $ r   )r   get_extra_restriction)r   aliasrelated_aliass      r   r   &ForeignObjectRel.get_extra_restriction   s    zz//EEr   c                     SU l         g)z
Set the related field's name, this is not available until later stages
of app loading, so set_field_name is called from
set_attributes_from_rel()
N
field_namer    s    r   set_field_nameForeignObjectRel.set_field_name   s     r   c                 d   U(       a  UR                   OU R                  R                   nU=(       d    U R                  nU R                  (       a!  U R                  (       a  XR                  :X  a  g U R
                  (       a  U R
                  $ UR                  U R                  (       a  S-   $ S-   $ )N_set )rX   r3   r   r   r   r   rZ   )r   r   optss      r   get_accessor_name"ForeignObjectRel.get_accessor_name   s}     $u{{););)A)A+++== EZZ$7$$$DMM&BBrBBr   c                 r    U(       a  U R                   R                  U5      $ U R                   R                  $ r   )r   get_reverse_path_inforeverse_path_infos)r   filtered_relations     r   get_path_infoForeignObjectRel.get_path_info   s+    ::334EFF::000r   c                 "    U R                  5       $ r   )r   r    s    r   r+   ForeignObjectRel.path_infos   s    !!##r   c                 "    U R                  5       $ )zl
Return the name of the cache key to use for storing an instance of the
forward model on the reverse model.
)r   r    s    r   get_cache_nameForeignObjectRel.get_cache_name   s    
 %%''r   )
r   r   r   r   r   r   r   r   r   r   NNNFNr   )-rW   
__module____qualname____firstlineno____doc__auto_createdconcreteeditableis_relationnullempty_strings_allowedr   r   r!   r$   propertyr'   r/   r3   r6   r:   r9   r@   rC   rG   rJ   rM   rP   r[   r^   re   ri   rp   r   r~   r   r   r   r   r   r   r   r+   r   __static_attributes__rr   r   r   r   r      s    LHHK D! 2     / /   
  
      ' ' & & & & % %2(.. " "
 
 
/
#
 &V(H87FC$1 $ $(r   r   c                   h   ^  \ rS rSrSr     S	U 4S jjrU 4S jr\U 4S j5       rS r	S r
SrU =r$ )
ManyToOneReli  a  
Used by the ForeignKey field to store information about the relation.

``_meta.get_fields()`` returns this class to provide access to the field
flags for the reverse relation.

Note: Because we somewhat abuse the Rel objects by using them as reverse
fields we get the funny situation where
``ManyToOneRel.many_to_one == False`` and
``ManyToOneRel.one_to_many == True``. This is unfortunate but the actual
ManyToOneRel class is a private API and there is work underway to turn
reverse relations into actual fields.
c	           
      8   > [         T	U ]  UUUUUUUS9  X0l        g )Nr   r   r   r   r   )superr   r   
r   r   r   r   r   r   r   r   r   rb   s
            r   r   ManyToOneRel.__init__  s3     	%1-# 	 	
 %r   c                 H   > [         TU ]  5       nUR                  SS 5        U$ )Nr3   )r   rp   rn   )r   ro   rb   s     r   rp   ManyToOneRel.__getstate__(  s#    $&		/4(r   c                 4   > [         TU ]  U R                  4-   $ r   )r   r^   r   r   rb   s    r   r^   ManyToOneRel.identity-  s    w4??"444r   c                     U R                   R                  R                  U R                  5      nUR                  (       d#  [
        R                  " SU R                  -  5      eU$ )zI
Return the Field in the 'to' object to which this relationship is tied.
zNo related field named '%s')r   rX   	get_fieldr   r   r   FieldDoesNotExist)r   r   s     r   get_related_fieldManyToOneRel.get_related_field1  sO     

  **4??;~~..-?  r   c                     U R                   =(       d*    U R                  R                  R                  R                  U l         g r   )r   r   rX   rw   r$   r    s    r   r   ManyToOneRel.set_field_name<  s(    //ETZZ-=-=-@-@-E-Er   r   r   )rW   r   r   r   r   r   rp   r   r^   r   r   r   __classcell__rb   s   @r   r   r     sH    & %.
 5 5	F Fr   r   c                   :   ^  \ rS rSrSr     SU 4S jjrSrU =r$ )OneToOneReli@  z
Used by OneToOneField to store information about the relation.

``_meta.get_fields()`` returns this class to provide access to the field
flags for the reverse relation.
c	                 <   > [         T	U ]  UUUUUUUUS9  SU l        g )Nr   F)r   r   r   r   s
            r   r   OneToOneRel.__init__H  s8     	%1-# 	 		
 r   )r   r   )rW   r   r   r   r   r   r   r   r   s   @r   r   r   @  s#      r   r   c                   Z   ^  \ rS rSrSr       SU 4S jjr\U 4S j5       rS rSr	U =r
$ )ManyToManyRelia  z
Used by ManyToManyField to store information about the relation.

``_meta.get_fields()`` returns this class to provide access to the field
flags for the reverse relation.
c
                    > [         T
U ]  UUUUUS9  U(       a  U	(       d  [        S5      eXpl        U(       a  U(       d  [        S5      eXl        X`l        Xl        g )N)r   r   r   z4Can't supply a through model and db_constraint=Falsez5Cannot specify through_fields without a through model)r   r   
ValueErrorthroughthrough_fieldsr   db_constraint)r   r   r   r   r   r   r   r   r   r   rb   s             r   r   ManyToManyRel.__init__i  sa     	%1- 	 	
 =STT'TUU,&*r   c                 r   > [         TU ]  U R                  [        U R                  5      U R
                  4-   $ r   )r   r^   r   r   r   r   r   s    r   r^   ManyToManyRel.identity  s8    wLL$--.#
 
 	
r   c                 6   U R                   R                  nU R                  (       a  UR                  U R                  S   5      nOEUR                   H5  n[        USS5      nU(       d  M  UR                  U R                  :X  d  M5    O   WR                  S   $ )zr
Return the field in the 'to' object to which this relationship is tied.
Provided for symmetry with ManyToOneRel.
r   r'   N)r   rX   r   r   fieldsgetattrr   foreign_related_fields)r   r   r   rels       r   r   ManyToManyRel.get_related_field  s{    
 ||!!NN4#6#6q#9:Ee^T:3399

2 % ++A..r   )r   r   r   r   )NNNTNNT)rW   r   r   r   r   r   r   r^   r   r   r   r   s   @r   r   r   a  sB     +> 
 
/ /r   r   )r   r   django.corer   django.utils.deprecationr   django.utils.functionalr   django.utils.hashabler   r   r   mixinsr	   r   r   r   r   rr   r   r   <module>r      sZ   	  " = 3 /  #h( h(V;F# ;F|, B</$ </r   