o 3a+@sdZddlmZddlmZddlmZddlmZddl m Z Gdd d e Z Gd d d e Z Gd d d e Z Gddde ZdS)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. ) exceptions)cached_property) make_hashable)BLANK_CHOICE_DASH)FieldCacheMixinc@s0eZdZdZdZdZdZdZdZdZ  d8ddZ e ddZ e d d Z ed d Zed dZe ddZe ddZe ddZe ddZe ddZddZddZeddZdd Zed!d"Zd#d$Zd%d&Zdedd'fd(d)Zd*d+Zd,d-Z d.d/Z!d0d1Z"d9d2d3Z#d9d4d5Z$d6d7Z%dS):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. TFNcCsF||_||_||_||_|durin||_||_||_d|_d|_dS)NFT) fieldmodel related_namerelated_query_namelimit_choices_to parent_link on_delete symmetricalmultiple)selfr tor r r rrrI/usr/lib/python3/dist-packages/django/db/models/fields/reverse_related.py__init__'s zForeignObjectRel.__init__cC|SN) is_hiddenrrrrhidden8zForeignObjectRel.hiddencC |jSr)r r rrrrname<s zForeignObjectRel.namecCs|jSr)r rrrr remote_field@szForeignObjectRel.remote_fieldcCs,|dj}t|dkrtd|dS)z When filtering against this relation, return the field on the remote model against which the filtering should happen. rz1Can't use target_field for multicolumn relations.r) get_path_info target_fieldslenr FieldError)rr"rrr target_fieldDs  zForeignObjectRel.target_fieldcCs|jjstd|jjS)NzVThis property can't be accessed before self.field.contribute_to_class has been called.)r r AttributeErrorrrrr related_modelOs zForeignObjectRel.related_modelcC|jjSr)r many_to_manyrrrrr)VrzForeignObjectRel.many_to_manycCr(r)r one_to_manyrrrr many_to_oneZrzForeignObjectRel.many_to_onecCr(r)r r+rrrrr*^rzForeignObjectRel.one_to_manycCr(r)r one_to_onerrrrr,brzForeignObjectRel.one_to_onecC |j|Sr)r get_lookup)r lookup_namerrrr.f zForeignObjectRel.get_lookupcCrr)r get_internal_typerrrrr1i z"ForeignObjectRel.get_internal_typecCr(r)r db_typerrrrr3lrzForeignObjectRel.db_typecCs dt|j|jjj|jjjfS)Nz <%s: %s.%s>)type__name__r'_meta app_label model_namerrrr__repr__ps zForeignObjectRel.__repr__c Cs,|j|j|j|jt|j|j|j|j|j f Sr) r r r r rr rrrrrrrridentitywszForeignObjectRel.identitycCst||jstS|j|jkSr) isinstance __class__NotImplementedr:)rotherrrr__eq__s  zForeignObjectRel.__eq__cCs t|jSr)hashr:rrrr__hash__r2zForeignObjectRel.__hash__rcCs@|p|j}|jj|}|r|j|}|r|ngdd|DS)a Return choices with a default blank choices included, for use as