Ë
    ùi¯e%2  ã                   ó°   — d Z ddlZddlmZ ddlmZ ddlmZ ddlm	Z	 ddl
mZ dd	lmZ  G d
„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Zy)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                   ón  — e Zd ZdZdZdZdZdZdZdZ		 	 	 	 	 d$d„Z
ed„ «       Zed„ «       Zed„ «       Zed	„ «       Zed
„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zd„ Zd„ Zd„ Zd„ Zed„ «       Zd„ Zed„ «       Zd„ Zd„ Zd„ Zde ddfd„Z!d„ Z"d„ Z#d„ Z$d„ Z%d„ Z&d%d „Z'd%d!„Z(ed"„ «       Z)d#„ Z*y)&ÚForeignObjectRelzº
    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                 óŠ   — || _         || _        || _        || _        |€i n|| _        || _        || _        d| _        d| _        y )NFT)	ÚfieldÚmodelÚrelated_nameÚrelated_query_nameÚlimit_choices_toÚparent_linkÚ	on_deleteÚsymmetricalÚmultiple)Úselfr   Útor   r   r   r   r   s           úPE:\TRUCKING_PROJECT\Lib\site-packages\django/db/models/fields/reverse_related.pyÚ__init__zForeignObjectRel.__init__)   sP   € ð ˆŒ
ØˆŒ
Ø(ˆÔØ"4ˆÔØ&6Ð&>¡ÐDTˆÔØ&ˆÔØ"ˆŒà ˆÔØˆ�ó    c                 ó"   — | j                  «       S ©N)Ú	is_hidden©r   s    r   ÚhiddenzForeignObjectRel.hiddenB   s   € à�~‰~ÓÐr   c                 ó6   — | j                   j                  «       S r   )r   r   r   s    r   ÚnamezForeignObjectRel.nameF   s   € à�z‰z×,Ñ,Ó.Ð.r   c                 ó   — | j                   S r   )r   r   s    r   Úremote_fieldzForeignObjectRel.remote_fieldJ   s   € à�z‰zÐr   c                 ó„   — | j                   d   j                  }t        |«      dkD  rt        j                  d«      ‚|d   S )z�
        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_fieldzForeignObjectRel.target_fieldN   sH   € ð Ÿ™¨Ñ+×9Ñ9ˆÜˆ}Ó Ò!Ü×'Ñ'ØCóð ð ˜QÑÐr   c                 óp   — | j                   j                  st        d«      ‚| j                   j                  S )NzVThis property can't be accessed before self.field.contribute_to_class has been called.)r   r   ÚAttributeErrorr   s    r   Úrelated_modelzForeignObjectRel.related_model[   s3   € à�z‰z×ÒÜ ð#óð ð �z‰z×ÑÐr   c                 ó.   — | j                   j                  S r   )r   Úmany_to_manyr   s    r   r/   zForeignObjectRel.many_to_manyd   s   € à�z‰z×&Ñ&Ð&r   c                 ó.   — | j                   j                  S r   )r   Úone_to_manyr   s    r   Úmany_to_onezForeignObjectRel.many_to_oneh   ó   € à�z‰z×%Ñ%Ð%r   c                 ó.   — | j                   j                  S r   )r   r2   r   s    r   r1   zForeignObjectRel.one_to_manyl   r3   r   c                 ó.   — | j                   j                  S r   )r   Ú
one_to_oner   s    r   r6   zForeignObjectRel.one_to_onep   s   € à�z‰z×$Ñ$Ð$r   c                 ó8   — | j                   j                  |«      S r   )r   Ú
get_lookup)r   Úlookup_names     r   r8   zForeignObjectRel.get_lookupt   s   € Ø�z‰z×$Ñ$ [Ó1Ð1r   c                 ó6   — | j                   j                  «       S r   )r   Úget_lookupsr   s    r   r;   zForeignObjectRel.get_lookupsw   s   € Ø�z‰z×%Ñ%Ó'Ð'r   c                 ó8   — | j                   j                  |«      S r   )r   Úget_transform)r   r!   s     r   r=   zForeignObjectRel.get_transformz   s   € Ø�z‰z×'Ñ'¨Ó-Ð-r   c                 ó6   — | j                   j                  «       S r   )r   Úget_internal_typer   s    r   r?   z"ForeignObjectRel.get_internal_type}   s   € Ø�z‰z×+Ñ+Ó-Ð-r   c                 ó.   — | j                   j                  S r   )r   Údb_typer   s    r   rA   zForeignObjectRel.db_type€   s   € à�z‰z×!Ñ!Ð!r   c                 ó¸   — dt        | «      j                  ›d| j                  j                  j                  ›d| j                  j                  j
                  ›d�S )Nú<z: ú.ú>)ÚtypeÚ__name__r-   Ú_metaÚ	app_labelÚ
model_namer   s    r   Ú__repr__zForeignObjectRel.__repr__„   sC   � ä�‹J×ÓØ×Ñ×$Ñ$×.Ó.Ø×Ñ×$Ñ$×/Ó/ð
ð 	
r   c           	      óÞ   — | j                   | j                  | j                  | j                  t	        | j
                  «      | j                  | j                  | j                  | j                  f	S r   )
r   r   r   r   r   r   r   r   r   r   r   s    r   ÚidentityzForeignObjectRel.identity‹   s\   € ð �J‰JØ�J‰JØ×ÑØ×#Ñ#Ü˜$×/Ñ/Ó0Ø×ÑØ�N‰NØ×ÑØ�M‰Mð

ð 
	
r   c                 ól   — t        || j                  «      st        S | j                  |j                  k(  S r   )Ú
isinstanceÚ	__class__ÚNotImplementedrM   )r   Úothers     r   Ú__eq__zForeignObjectRel.__eq__™   s)   € Ü˜% §¡Ô0Ü!Ð!Ø�}‰} §¡Ñ.Ð.r   c                 ó,   — t        | j                  «      S r   )ÚhashrM   r   s    r   Ú__hash__zForeignObjectRel.__hash__ž   s   € Ü�D—M‘MÓ"Ð"r   c                 ó^   — | j                   j                  «       }|j                  dd «       |S )Nr&   )Ú__dict__ÚcopyÚpop)r   Ústates     r   Ú__getstate__zForeignObjectRel.__getstate__¡   s)   € Ø—‘×"Ñ"Ó$ˆð 	�	‰	�, Ô%Øˆr   © c                 óð   — |xs | j                   }| j                  j                  j                  |«      }|r |j                  |Ž }|r|ng |D �cg c]  }|j
                  t        |«      f‘Œ c}z   S c c}w )a  
        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   r-   Ú_default_managerÚcomplex_filterÚorder_byÚpkÚstr)r   Úinclude_blankÚblank_choicer   ÚorderingÚqsÚxs          r   Úget_choiceszForeignObjectRel.get_choices­   so   € ð ,ÒD¨t×/DÑ/DÐØ×Ñ×0Ñ0×?Ñ?Ð@PÓQˆÙØ�—‘˜hÐ'ˆBÙ -‘°2ÐRTÖ9UÈQ¸1¿4¹4ÄÀQÃº.Ò9UÑUÐUùÒ9Us   ÁA3c                 óT   — t        | j                  «      xr | j                  d   dk(  S )z$Should the related object be hidden?r%   ú+)Úboolr   r   s    r   r   zForeignObjectRel.is_hiddenÁ   s(   € ä�D×%Ñ%Ó&ÒG¨4×+<Ñ+<¸RÑ+@ÀCÑ+GÐGr   c                 ój   — t        j                  dt        «       | j                  j	                  «       S )NzWForeignObjectRel.get_joining_columns() is deprecated. Use get_joining_fields() instead.)ÚwarningsÚwarnr   r   Úget_reverse_joining_columnsr   s    r   Úget_joining_columnsz$ForeignObjectRel.get_joining_columnsÅ   s+   € Ü�‰ð,ä$ô	
ð
 �z‰z×5Ñ5Ó7Ð7r   c                 ó6   — | j                   j                  «       S r   )r   Úget_reverse_joining_fieldsr   s    r   Úget_joining_fieldsz#ForeignObjectRel.get_joining_fieldsÍ   s   € Ø�z‰z×4Ñ4Ó6Ð6r   c                 ó:   — | j                   j                  ||«      S r   )r   Úget_extra_restriction)r   ÚaliasÚrelated_aliass      r   rv   z&ForeignObjectRel.get_extra_restrictionÐ   s   € Ø�z‰z×/Ñ/°¸uÓEÐEr   c                 ó   — d| _         y)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_namezForeignObjectRel.set_field_nameÓ   s   € ð ˆ�r   c                 ó(  — |r|j                   n| j                  j                   }|xs | j                  }| j                  r| j                  r|| j                  k(  ry | j
                  r| j
                  S |j                  | j                  rdz   S dz   S )NÚ_setÚ )rH   r-   r   r   r   r   rJ   )r   r   Úoptss      r   Úget_accessor_namez"ForeignObjectRel.get_accessor_nameÝ   s   € ñ $ˆu�{Š{¨×);Ñ);×)AÑ)AˆØÒ+˜×+Ñ+ˆØ�=Š=ð ×Ò E¨T¯Z©ZÒ$7ØØ×ÒØ×$Ñ$Ð$Ø�‰¨D¯MªM &ÑBÐB¸rÑBÐBr   c                 óh   — |r| j                   j                  |«      S | j                   j                  S r   )r   Úget_reverse_path_infoÚreverse_path_infos)r   Úfiltered_relations     r   Úget_path_infozForeignObjectRel.get_path_infoï   s+   € ÙØ—:‘:×3Ñ3Ð4EÓFÐFà—:‘:×0Ñ0Ð0r   c                 ó"   — | j                  «       S r   )r…   r   s    r   r&   zForeignObjectRel.path_infosõ   s   € à×!Ñ!Ó#Ð#r   c                 ó"   — | j                  «       S )z„
        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_namezForeignObjectRel.get_cache_nameù   s   € ð
 ×%Ñ%Ó'Ð'r   ©NNNFNr   )+rG   Ú
__module__Ú__qualname__Ú__doc__Úauto_createdÚconcreteÚeditableÚis_relationÚnullÚempty_strings_allowedr   r   r   r!   Úpropertyr#   r*   r-   r/   r2   r1   r6   r8   r;   r=   r?   rA   rK   rM   rS   rV   r\   r   ri   r   rq   rt   rv   r{   r€   r…   r&   rˆ   r]   r   r   r   r      s—  „ ñð €LØ€HØ€HØ€Kð €DØ!Ðð ØØØØóð2 ñ ó ð ð ñ/ó ð/ð ñó ðð ñ
 ó ð
 ð ñ ó ð ð ñ'ó ð'ð ñ&ó ð&ð ñ&ó ð&ð ñ%ó ð%ò2ò(ò.ò.ð ñ"ó ð"ò
ð ñ
ó ð
ò/ò
#ò
ð Ø&ØØóVò(Hò8ò7òFòóCó$1ð ñ$ó ð$ó(r   r   c                   óX   ‡ — e Zd ZdZ	 	 	 	 	 dˆ fd„	Zˆ fd„Zeˆ fd„«       Zd„ Zd„ Z	ˆ xZ
S )ÚManyToOneRela+  
    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	           	      ó@   •— t         ‰	| �  |||||||¬«       || _        y )N©r   r   r   r   r   )Úsuperr   rz   ©
r   r   r   rz   r   r   r   r   r   rP   s
            €r   r   zManyToOneRel.__init__  s5   ø€ ô 	‰ÑØØØ%Ø1Ø-Ø#Øð 	ô 	
ð %ˆ�r   c                 óH   •— t         ‰| �  «       }|j                  dd «       |S )Nr-   )r˜   r\   rZ   )r   r[   rP   s     €r   r\   zManyToOneRel.__getstate__'  s#   ø€ Ü‘Ñ$Ó&ˆØ�	‰	�/ 4Ô(Øˆr   c                 ó4   •— t         ‰| �  | j                  fz   S r   )r˜   rM   rz   ©r   rP   s    €r   rM   zManyToOneRel.identity,  s   ø€ ä‰wÑ 4§?¡?Ð"4Ñ4Ð4r   c                 óÀ   — | j                   j                  j                  | j                  «      }|j                  s"t        j                  d| j                  z  «      ‚|S )zY
        Return the Field in the 'to' object to which this relationship is tied.
        zNo related field named '%s')r   rH   Ú	get_fieldrz   rŽ   r   ÚFieldDoesNotExist)r   r   s     r   Úget_related_fieldzManyToOneRel.get_related_field0  sO   € ð —
‘
× Ñ ×*Ñ*¨4¯?©?Ó;ˆØ�~Š~Ü×.Ñ.Ø-°·±Ñ?óð ð ˆr   c                 ó~   — | j                   xs* | j                  j                  j                  j                  | _         y r   )rz   r   rH   rb   r!   r   s    r   r{   zManyToOneRel.set_field_name;  s(   € ØŸ/™/ÒE¨T¯Z©Z×-=Ñ-=×-@Ñ-@×-EÑ-Eˆ�r   r‰   )rG   rŠ   r‹   rŒ   r   r\   r“   rM   r    r{   Ú__classcell__©rP   s   @r   r•   r•     sB   ø„ ñð& ØØØØõ%ô.ð
 ó5ó ð5ò	öFr   r•   c                   ó.   ‡ — e Zd ZdZ	 	 	 	 	 dˆ fd„	Zˆ xZS )ÚOneToOneRelzº
    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	           
      óB   •— t         ‰	| �  ||||||||¬«       d| _        y )Nr—   F)r˜   r   r   r™   s
            €r   r   zOneToOneRel.__init__G  s8   ø€ ô 	‰ÑØØØØ%Ø1Ø-Ø#Øð 	ô 		
ð ˆ�r   r‰   )rG   rŠ   r‹   rŒ   r   r¢   r£   s   @r   r¥   r¥   ?  s#   ø„ ñð ØØØØ÷ñ r   r¥   c                   óL   ‡ — e Zd ZdZ	 	 	 	 	 	 	 dˆ fd„	Zeˆ fd„«       Zd„ Zˆ xZS )ÚManyToManyRelz¼
    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         ‰
| �  |||||¬«       |r|	st        d«      ‚|| _        |r|st        d«      ‚|| _        || _        |	| _        y )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­   rP   s             €r   r   zManyToManyRel.__init__h  si   ø€ ô 	‰ÑØØØ%Ø1Ø-ð 	ô 	
ñ ™=ÜÐSÓTÐTØˆŒá¡'ÜÐTÓUÐUØ,ˆÔà&ˆÔØ*ˆÕr   c                 ór   •— t         ‰| �  | j                  t        | j                  «      | j
                  fz   S r   )r˜   rM   r«   r   r¬   r­   rœ   s    €r   rM   zManyToManyRel.identity‡  s8   ø€ ä‰wÑØ�L‰LÜ˜$×-Ñ-Ó.Ø×Ñð#
ñ 
ð 	
r   c                 ó  — | j                   j                  }| j                  r|j                  | j                  d   «      }n<|j                  D ]-  }t        |dd«      }|sŒ|j                  | j                  k(  sŒ- n j                  d   S )zŠ
        Return the field in the 'to' object to which this relationship is tied.
        Provided for symmetry with ManyToOneRel.
        r   r#   N)r«   rH   r¬   rž   ÚfieldsÚgetattrr   Úforeign_related_fields)r   r   r   Úrels       r   r    zManyToManyRel.get_related_field�  s~   € ð
 �|‰|×!Ñ!ˆØ×ÒØ—N‘N 4×#6Ñ#6°qÑ#9Ó:‰EàŸ™ò �Ü˜e ^°TÓ:�Ú˜3Ÿ9™9¨¯
©
Ó2Ùðð ×+Ñ+¨AÑ.Ð.r   )NNNTNNT)	rG   rŠ   r‹   rŒ   r   r“   rM   r    r¢   r£   s   @r   r¨   r¨   `  s=   ø„ ñð ØØØØØØõ+ð> ó
ó ð
ö/r   r¨   )rŒ   rn   Údjango.corer   Údjango.utils.deprecationr   Údjango.utils.functionalr   Údjango.utils.hashabler   r~   r   Úmixinsr	   r   r•   r¥   r¨   r]   r   r   ú<module>r¹      sZ   ðñ	ó å "Ý =Ý 3Ý /å Ý #ôh(�ô h(ôV;FÐ#ô ;Fô|�,ô ôB</Ð$õ </r   