HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberCP/lib/python3.10/site-packages/django/db/models/__pycache__/base.cpython-310.pyc
o

�h��@s8ddlZddlZddlZddlmZddlmZddlmZddl	Z	ddl
mZddlm
Z
ddlmZddlmZmZmZmZmZmZdd	lmZmZmZmZmZmZdd
lmZm Z m!Z!m"Z"m#Z#ddl$m%Z%ddl&m'Z'm(Z(dd
l)m*Z*m+Z+ddl,m-Z-ddl.m/Z/m0Z0m1Z1m2Z2ddl3m4Z4ddl5m6Z6ddl7m8Z8ddl9m:Z:m;Z;ddl<m=Z=m>Z>m?Z?m@Z@mAZAddlBmCZCmDZDddlEmFZFddlGmHZHddlImJZJmKZKddlLmMZNGdd�d�ZOeO�ZPdd�ZQdd�ZRGd d!�d!eS�ZTGd"d#�d#�ZUGd$d%�d%�ZVGd&d'�d'eCeTd(�ZWd2d)d*�ZXd+d,�ZYd-d.�ZZd/d0�Z[d1e[_\dS)3�N)�
partialmethod)�chain)�
sync_to_async)�apps)�settings)�checks)�NON_FIELD_ERRORS�FieldDoesNotExist�
FieldError�MultipleObjectsReturned�ObjectDoesNotExist�ValidationError)�DJANGO_VERSION_PICKLE_KEY�
DatabaseError�
connection�connections�router�transaction)�NOT_PROVIDED�ExpressionWrapper�IntegerField�Max�Value��
LOOKUP_SEP)�CheckConstraint�UniqueConstraint)�CASCADE�	Collector)�RawSQL)�ForeignObjectRel�
OneToOneField�lazy_related_operation�resolve_relation)�Coalesce)�Manager)�Options)�F�Q)�class_prepared�	post_init�	post_save�pre_init�pre_save)�
AltersData�make_model_tuple)�	force_str)�
make_hashable)�capfirst�
get_text_list)�gettext_lazyc@seZdZdd�Zdd�ZdS)�DeferredcC�dS�Nz<Deferred field>���selfr8r8�H/usr/local/CyberCP/lib/python3.10/site-packages/django/db/models/base.py�__repr__;�zDeferred.__repr__cCr6r7r8r9r8r8r;�__str__>r=zDeferred.__str__N)�__name__�
__module__�__qualname__r<r>r8r8r8r;r5:sr5cCst|||d|j|fd��S)z�
    Create exception subclass. Used by ModelBase below.

    The exception is created in a way that allows it to be pickled, assuming
    that the returned exception class will be added as an attribute to the
    'attached_to' class.
    z%s.%s)r@rA)�typerA)�name�bases�module�attached_tor8r8r;�subclass_exceptionEs��rGcCst�|�o
t|d�S)N�contribute_to_class)�inspect�isclass�hasattr)�valuer8r8r;�_has_contribute_to_classWsrMcsHeZdZdZ�fdd�Zdd�Zdd�Zedd	��Zed
d��Z	�Z
S)�	ModelBasezMetaclass for all models.c#	s�t�j}dd�|D�}|s|||||�S|�d�}d|i}|�dd�}	|	dur+|	|d<|�dd�}
i}|��D]\}}
t|
�rD|
||<q7|
||<q7|||||fi|��}t|
dd�}|
pat|dd�}t|dd�}d}t�|�}t|d	d�dur�|dur�|s�td
||f��n|j	}|�
dt||��|s�|�
dtdt
dd
�|D��p�tf||d��|�
dtdt
dd
�|D��p�tf||d��|r�|js�t|d�s�|j|j_t|d�s�|j|j_|jj}|r�|r�|jr�td||jf��|��D]
\}}
|�
||
�q�t|jj|jj|jj�}dd�|D�}|�rad}dd�|D�D]-}|jj�r/|jj�r-td|���q|du�r8|}�q|jj|jju�rGtd|���q|du�rTtd|��|j�|�|jj|j_n||j_i}t|g|�D]7}t|d��sx�qn||k�r�|jj�s��qn|jjD]}t |t!��r�|j"j#�r�t$||j"j%�}||t&|�<�q��qnt'�}|�(�D�]}||v�s�t|d��s�|�)|j*��q�|jj|jj}|jj�s6|D]}|j+|v�r�t,d|j+||j-f��|�.|j+��q�|jj}t&|�}||v�r�||}n0|�s-d|jj/}t!|t0|ddd�}||v�r t,d|||j-f��t||��s,|�
||�nd}||jj1|<nI|jj1�2�} |D]9}|j+|v�rv|j+|j*v�rv|j+|v�rvt2�3|�}!|�
|j+|!�|j4�rv| ��D]\}}"||"k�rt|!| |<�qg�q>|jj1�)| �|jjD]/}|j+|v�r�|jj�s�t,d|j+||j-f���q�t2�3|�}|jj�s�d|_5|�
|j+|��q��q�dd�|jj6D�|j_6|�r�d|
_|
|_7|S|�8�|jj�9|jj:|�|S) NcSsg|]	}t|t�r|�qSr8)�
isinstancerN)�.0�br8r8r;�
<listcomp>d�z%ModelBase.__new__.<locals>.<listcomp>r@�
__classcell__�Meta�abstractF�_meta�	app_labelzfModel class %s.%s doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.�DoesNotExistcs�(�|]}t|d�r|jjs|jVqdS�rWN)rKrWrVrY�rP�xr8r8r;�	<genexpr>�����
�z$ModelBase.__new__.<locals>.<genexpr>)rFrcsrZr[)rKrWrVrr\r8r8r;r^�r_�ordering�
get_latest_byz'%s cannot proxy the swapped model '%s'.cSsh|]}|j�qSr8�rC�rP�fr8r8r;�	<setcomp>�sz$ModelBase.__new__.<locals>.<setcomp>cSsg|]	}t|d�r|�qS)rW)rK)rP�klsr8r8r;rR�rSzOAbstract base class containing model fields not permitted for proxy model '%s'.zAProxy model '%s' has more than one non-abstract model base class.z6Proxy model '%s' has no non-abstract model base class.zRLocal field %r in class %r clashes with field of the same name from base class %r.z%s_ptrT)�	on_deleterC�auto_created�parent_linkztAuto-generated field '%s' in class %r for parent_link to base class %r clashes with declared field of the same name.cSsg|]}t�|��qSr8)�copy�deepcopy)rP�idxr8r8r;rRas
�);�super�__new__�pop�itemsrM�getattrr�get_containing_app_config�RuntimeError�label�add_to_classr&rG�tuplerrrVrKr`rWra�proxy�swapped�	TypeErrorr�local_fields�local_many_to_many�private_fields�fields�concrete_model�setup_proxy�reversedrOr!�remote_fieldrir#�modelr/�set�mro�update�__dict__rCr
r?�add�
model_namer�parentsrjrk�
one_to_one�
mti_inherited�indexesrU�_prepare�register_modelrX)#�clsrCrD�attrs�kwargs�	super_newr�rE�	new_attrs�	classcell�	attr_meta�contributable_attrs�obj_name�obj�	new_classrV�meta�	base_metarX�
app_config�is_proxy�
new_fields�field_names�base�parent�parent_links�field�related�inherited_attributes�
parent_fields�base_key�	attr_name�base_parents�	new_fieldri��	__class__r8r;rn_s�



���������




��

��
���
���
���


�
���
�

�
����

�
�zModelBase.__new__cCs(t|�r|�||�dSt|||�dS�N)rMrH�setattr)r�rCrLr8r8r;ruqszModelBase.add_to_classcCs|j}|�|�|jr,t|jdd�|_t|jdd�|_|jjr,|j}|jj}t	t
||�|jdurBd|jd�
dd�|jD��f|_tj�|j�}|rQt|d	|�|jsqtd
d�|jD��retd|j��t�}d|_|�d|�|jjD]
}|js|�|�qutj|d
�dS)z7Create some methods once self._meta has been populated.T)�is_nextFNz%s(%s)�, cs��|]}|jVqdSr�rbrcr8r8r;r^���z%ModelBase._prepare.<locals>.<genexpr>�get_absolute_urlcss�|]}|jdkVqdS)�objectsNrbrcr8r8r;r^���zOModel %s must specify a custom Manager, because it has a field named 'objects'.r�)�sender)rWr��order_with_respect_tor�_get_next_or_previous_in_order�get_next_in_order�get_previous_in_orderr�r�r"�make_foreign_order_accessors�__doc__r?�joinr}r�ABSOLUTE_URL_OVERRIDES�get�label_lowerr��managers�any�
ValueErrorr%rhrur�rC�set_name_with_modelr)�send)r��opts�wrt�remote�get_absolute_url_override�manager�indexr8r8r;r�wsL
��	
����
�zModelBase._preparecC�|jjSr�)rW�base_manager�r�r8r8r;�
_base_manager��zModelBase._base_managercCr�r�)rW�default_managerr�r8r8r;�_default_manager�r�zModelBase._default_manager)r?r@rAr�rnrur��propertyr�r�rTr8r8r�r;rN\s7
rNc@seZdZddd�ZdS)�ModelStateFieldsCacheDescriptorNcCs|dur|Si}|_|Sr�)�fields_cache)r:�instancer��resr8r8r;�__get__�s
z'ModelStateFieldsCacheDescriptor.__get__r�)r?r@rAr�r8r8r8r;r��sr�c@seZdZdZdZdZe�ZdS)�
ModelStatezStore model instance state.NT)r?r@rAr��db�addingr�r�r8r8r8r;r��s

r�cs�eZdZ�fdd�Zedd��Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zd�dd�Z
dd�Zee
e�Zdd�Zd�dd�Zd�dd�Zdd�Z	d�d!d"�Zd#e_	d�d$d%�Zd#e_	 	 	 		d�d&d'�Zd#e_d(d)�Z	 		 	 		d�d*d+�Zd,d-�Zd.d/�Zd�d0d1�Zd�d2d3�Zd#e_d�d4d5�Zd#e_d6d7�Z d8d9�Z!d:d;�Z"d�d<d=�Z#d>d?�Z$d@dA�Z%d�dBdC�Z&d�dDdE�Z'dFdG�Z(dHdI�Z)dJdK�Z*dLdM�Z+dNdO�Z,d�dPdQ�Z-d�dRdS�Z.d�dTdU�Z/edVdW��Z0edXdY��Z1edZd[��Z2ed\d]��Z3ed^d_��Z4ed`da��Z5edbdc��Z6eddde��Z7edfdg��Z8edhdi��Z9edjdk��Z:edldm��Z;edndo��Z<edpdq��Z=edrds��Z>edtdu��Z?edvdw��Z@edxdy��ZAedzd{��ZBed|d}��ZCed~d��ZDed�d���ZE�ZFS)��Modelcs�|j}|j}t}t}|jrtd��tj|||d�t�|_	t
|�t
|j�kr*td��|sHt
|j�}t||�D]\}}	||ur?q6|||	j|�q6n0t
|j�}t||�D]%\}}	||ur[qR|||	j|�|�|	jt�turwt|j�d|	j�d���qR|D]t}	d}
|	j|vr�|	jdur�qz|r�t|	jt�r�z
|�|	j�}d}
Wn9ty�z|�|	j�}Wn
ty�|	��}YnwYnwz|�|	j�}Wnty�|	��}Ynw|	��}|
r�||ur�|||	j|�qz||ur�|||	j|�qz|�rJ|j}d}
|��D]7\}}||v�r||u�r||||�q�z|�|�Wnt�y&|
|f7}
Yq�w||u�r2||||�q�|
�rJd	�d
d�|
D��}t|j �d|����t!��"�t#j||d
�dS)Nz'Abstract models cannot be instantiated.)r��argsr�z'Number of args exceeds number of fieldsz8() got both positional and keyword arguments for field '�'.FTr8r�css�|]}t|�VqdSr�)�repr)rP�nr8r8r;r^6��z!Model.__init__.<locals>.<genexpr>z%() got unexpected keyword arguments: )r�r�)$r�rWr��DEFERREDrVryr,r�r��_state�len�concrete_fields�
IndexError�iter�zip�attnamer}rorCrrA�columnrOr�r �KeyError�get_default�_property_namesrp�	get_fieldr	r�r?rm�__init__r*)r:r�r�r�r��_setattr�	_DEFERRED�fields_iter�valr��is_related_object�rel_obj�property_names�
unexpected�proprL�unexpected_namesr�r8r;r��s�
�
���	������

��
���
zModel.__init__csPt|�t|jj�krt|����fdd�|jjD�}||�}d|j_||j_|S)Ncs"g|]
}|j�vr
t��nt�qSr8)r��nextr�rc�r��values_iterr8r;rRBs��z!Model.from_db.<locals>.<listcomp>F)r�rWr�r�r�r�r�)r�r�r��values�newr8r�r;�from_db>s�z
Model.from_dbcCsd|jj|fS)Nz<%s: %s>)r�r?r9r8r8r;r<KszModel.__repr__cCsd|jj|jfS)Nz%s object (%s))r�r?�pkr9r8r8r;r>Nsz
Model.__str__cCsBt|t�stS|jj|jjkrdS|j}|dur||uS||jkS�NF)rOr��NotImplementedrWr~r)r:�other�my_pkr8r8r;�__eq__Qs

zModel.__eq__cCs|jdur	td��t|j�S)Nz8Model instances without primary key value are unhashable)rry�hashr9r8r8r;�__hash__[s

zModel.__hash__cCs.|��}tj|t<|jj|jjf}t|f|fSr�)�__getstate__�django�__version__rrWrX�object_name�model_unpickle)r:�data�class_idr8r8r;�
__reduce__`s
zModel.__reduce__cCs�|j��}t�|d�|d<|dj��|d_g}|��D]\}}t|t�r0|�|t|�f�q|rC||d<|D]	\}}|�|�q9|S)z0Hook to allow choosing the attributes to pickle.r��_memoryview_attrs)	r�rjr�rprO�
memoryview�append�bytesro)r:�stater�attrrLr8r8r;rfs

�zModel.__getstate__cCs||�t�}|r|tjkrtjd|tjftdd�ntjdtdd�d|vr6|�d�D]
\}}t|�||<q+|j	�
|�dS)NzQPickled model instance's Django version %s does not match the current version %s.�)�
stacklevelz9Pickled model instance's Django version is not specified.r)r�rr	r
�warnings�warn�RuntimeWarningrorr�r�)r:r�pickled_versionrrLr8r8r;�__setstate__ws(

����zModel.__setstate__NcCs|p|j}t||jj�Sr�)rWrqrr�)r:r�r8r8r;�_get_pk_val�s
zModel._get_pk_valcCsD|jj��D]}|r||jjkrt||jj|�qt||jjj|�Sr�)rWr�r�rr��target_fieldr�)r:rLrir8r8r;�_set_pk_val�s
�zModel._set_pk_valcs�fdd��jjD�S)zU
        Return a set containing names of deferred fields for this instance.
        csh|]}|j�jvr|j�qSr8)r�r�rcr9r8r;re�s
�z,Model.get_deferred_fields.<locals>.<setcomp>)rWr�r9r8r9r;�get_deferred_fields�s
�zModel.get_deferred_fieldsc	s�|duri|_n*t|dd�}|D]}||vr||=|�|�q|s#dStdd�|D��r2tdt��d|i}|jjj||d�j	|j
d	�}|���|durVt|�}|j
|�}n�rh�fd
d�|jjD�}|j
|�}|��}|��}|jjD] }|j|vr|qtt||jt||j��|jr�|�|�r�|�|�qt|jjD]}|�|�r�|�|�q�|jjD]}|jr�|�|�r�|�|�q�|jj|j_dS)aU
        Reload field values from the database.

        By default, the reloading happens from the database this instance was
        loaded from, or by the read router if this instance wasn't loaded from
        any database. The using parameter will override the default.

        Fields can be used to specify which fields to reload. The fields
        should be an iterable of field attnames. If fields is None, then
        all non-deferred fields are reloaded.

        When accessing deferred fields of an instance, the deferred loading
        of the field will call this method.
        N�_prefetched_objects_cacher8css�|]}t|vVqdSr�rrcr8r8r;r^�r�z(Model.refresh_from_db.<locals>.<genexpr>zRFound "%s" in fields argument. Relations and transforms are not allowed in fields.r�)�hints�rcsg|]
}|j�vr|j�qSr8)r�rc��deferred_fieldsr8r;rR�s

�z)Model.refresh_from_db.<locals>.<listcomp>)r!rq�remover�r�rr�r��
db_manager�filterrr �list�onlyrWr�r�r�r��is_relation�	is_cached�delete_cached_value�related_objectsr|r�r�)	r:�usingr}�prefetched_objects_cacher�r"�db_instance_qs�db_instance�non_loaded_fieldsr8r$r;�refresh_from_db�sb
�����
�


�

�
�zModel.refresh_from_dbc���t|j�||d�IdHS)N)r/r})rr4)r:r/r}r8r8r;�arefresh_from_db�s�zModel.arefresh_from_dbcCs:z|j�|�}Wntyt||�YSwt||j�S)a�
        Return the value of the field name for this instance. If the field is
        a foreign key, return the id value instead of the object. If there's
        no Field object with this name on the model, return the model
        attribute's value.

        Used to serialize a field's value (in the serializer, or form output,
        for example). Normally, you would just access the attribute directly
        and not use this method.
        )rWr�r	rqr�)r:�
field_namer�r8r8r;�serializable_value�s�zModel.serializable_valueFc
Cs�|jdd�|ptj|j|d�}|r|s|rtd��|��}|dur?|s&dSt|�}|jj}|�	|�}|r>tdd�
|���n-|sl|rl||jjkrlt
�}|jjD]}|js`t|d�s`|�|j�qP|�	|�}	|	rlt|	�}|j||||d	�dS)
aa
        Save the current instance. Override this in a subclass if you want to
        control the saving process.

        The 'force_insert' and 'force_update' parameters can be used to insist
        that the "save" must be an SQL insert or update (or equivalent for
        non-SQL backends), respectively. Normally, they should not be set.
        �save)�operation_name�r�z6Cannot force both insert and updating in model saving.Nz_The following fields do not exist in this model, are m2m fields, or are non-concrete fields: %sr��through)r/�force_insert�force_update�
update_fields)� _prepare_related_fields_for_saver�db_for_writer�r�r �	frozensetrW�_non_pk_concrete_field_names�
differencer�r�r�r�r��primary_keyrKr�r��	save_base)
r:r=r>r/r?r%r��non_model_fieldsr��
loaded_fieldsr8r8r;r9�sB
���	�

�z
Model.saveTc�s�t|j�||||d�IdHS)N)r=r>r/r?)rr9)r:r=r>r/r?r8r8r;�asave7s��zModel.asavec	Cs|p	tj|j|d�}|r|s|rJ�|dus|sJ�|j}}|jjr'|jj}|j}|js7tj|||||d�|j	rBt
j|dd�}	nt
j|d�}	|	�d}
|sV|�
|||�}
|�|||p]|
|||�}Wd�n1slwY||j_d|j_|js�tj||||||d�dSdS)av
        Handle the parts of saving which should be done only once per save,
        yet need to be done in raw saves, too. This includes some sanity
        checks and signal sending.

        The 'raw' argument is telling save_base not to save any parent
        models and not to do any changes to the values before save. This
        is used by fixture loading.
        r;N)r�r��rawr/r?F)r/�	savepoint)r/)r�r��createdr?rJr/)rrAr�rWrwr~rhr-r�r�r�atomic�mark_for_rollback_on_error�
_save_parents�_save_tabler�r�r�r+)r:rJr=r>r/r?r��originr��context_manager�parent_inserted�updatedr8r8r;rFCsV
���

��zModel.save_basec
Cs�|j}d}|j��D]Q\}}|r/t||jjj�dur/t||j�dur/t||jjjt||j��|j|||d�}|j||||d�}	|	sDd}|r[t||j|�	|j��|�
|�r[|�|�q
|S)z3Save all the parents of cls using values from self.FN)r�r/r?)r�r/r?r=T)rWr�rprqrr�r�rOrPrr,r-)
r:r�r/r?r��insertedr�r�rSrTr8r8r;rO�s2���

�zModel._save_parentscs�|j�dd��jD�}�r�fdd�|D�}����}|dur-�j���}t��jj|�|du}	|	s;|s7�r;td��d}
�sQ|sQ�jj	rQ�jj
rQ�jj
turQd}|	r�|s�|j�
|�}��fdd�|D�}�ph|}
��||||�|
�}
|r{|
s{td	���r�|
s�td
��|
s�jr��j}|���}|j�
|�jdi|��jtttd�td�t�d
�td��d�d�_�j}|	s��fdd�|D�}�j}��|j|||��}|r�t|d|�D]\}}t�|j|�q�|
S)zp
        Do the heavy-lifting involved in saving. Update or insert the data
        for a single table.
        cSsg|]}|js|�qSr8�rErcr8r8r;rR�sz%Model._save_table.<locals>.<listcomp>cs$g|]}|j�vs|j�vr|�qSr8)rCr�rc)r?r8r;rR�s
�Nz5Cannot force an update in save() with no primary key.FTcs.g|]}|d�rt�|j�n|��d�f�qSr)rqr�r-rc)rJr:r8r;rR�s���z&Forced update did not affect any rows.z0Save with update_fields did not affect any rows.�_order�)�output_fieldr)�_order__maxrZcsg|]	}|�jur|�qSr8)�
auto_fieldrc)r�r8r;rR�rSr8)rW�local_concrete_fieldsrr�get_pk_value_on_saver�r�r�r�r��defaultrr�r/�
_do_updaterr��get_filter_kwargs_for_objectr(�	aggregater$rrrrrW�db_returning_fields�
_do_insertr�)r:rJr�r=r>r/r?�non_pks�pk_val�pk_setrT�base_qsr��
forced_updater��filter_argsr}�returning_fields�resultsrLr8)r�rJr:r?r;rP�s�

�
������

�����	���zModel._save_tablecCsX|j|d�}|s|dup|��S|jjr%|s%|��o$|�|�dkp$|��S|�|�dkS)z�
        Try to update the model. Return True if the model was updated (if an
        update query was done and a matching row was found in the DB).
        r#Nr)r(�existsrW�select_on_save�_update)r:rgr/rer�r?rh�filteredr8r8r;r_s	�zModel._do_updatecCs|j|g||||d�S)z�
        Do an INSERT. If returning_fields is defined then this method should
        return the newly created data for the model.
        )r}rjr/rJ)�_insert)r:r�r/r}rjrJr8r8r;rc s�zModel._do_insertcCs |jjD]U}|r
||vr
q|jrY|�|�rYt||jd�}|sq|jdur7|jjs.|j�	|�t
d||jf��t||j�|jvrGt
||j|�t||jj�t||j�krY|�	|�q|jjD]/}|rg||vrgq^|jr�|�|�r�t|d�r�|j|dd�}|r�|jdur�t
|�d|j�d���q^dS)NzH%s() prohibited to prevent data loss due to unsaved related object '%s'.�fk_field)r^zB() prohibited to prevent data loss due to unsaved related object 'r�)rWr�r+r,rqrCrr��multipler-r�r��empty_valuesr�rr|rK�get_cached_value)r:r:r}r�r�r8r8r;r@-sP
���
��������z&Model._prepare_related_fields_for_savecCs\|jdurtd|jj|jjjf��|ptj|j|d�}t||d�}|j	|g|d�|�
�S)NzC%s object can't be deleted because its %s attribute is set to None.r;)r/rQ)�keep_parents)rr�rWrr�rrAr�r�collect�delete)r:r/ru�	collectorr8r8r;rwcs
��zModel.deletec�r5)N)r/ru)rrw)r:r/rur8r8r;�adeleteps
��z
Model.adeletecCs2t||j�}tt|j��}t|�t|�|�dd�S)NT)�strings_only)rqr��dictr1�flatchoicesr0r�)r:r�rL�choices_dictr8r8r;�_get_FIELD_displayxs
�zModel._get_FIELD_displayc	Ks�|jstd��|rdnd}|rdnd}t||j�}tj|j|fd|��|jfgtjd�}tj||j�d|��|fgtjd�}|j	j
�|jj
�jd
i|���|��d	||jfd
|�}z|dWStyq|�d|j	jj��w)Nz8get_next/get_previous cannot be used on unsaved objects.�gt�lt��-�pk__)�	connector�__z%s%sz%spkrz!%s matching query does not exist.r8)rr�rqr�r(�createrC�AND�ORr�r�r/r�r�r(�order_byr�rYrWr)	r:r�r�r��op�order�param�q�qsr8r8r;�_get_next_or_previous_by_FIELD�s,&$���
��z$Model._get_next_or_previous_by_FIELDc	Cs�d|}t||�sR|r
dnd}|rdnd}|jj}|�|�}|jjjdi|��jdid||jj�d�jdi|jjj	|ji��i���
|�dd���}t|||�t
||�S)	Nz__%s_order_cacherr�rWz-_orderz
_order__%srXr8)rKrWr�r`r�r�r(r�rrCr�r�r�rq)r:r��	cachenamer�r��order_fieldrir�r8r8r;r��s.

�����	�
�
z$Model._get_next_or_previous_in_ordercs.�durt��|p�j}��fdd�|jD�S)Ncs,i|]}|j�vr|jtt�|j�|��qSr8)rCrrqr�)rPr���excluder:r8r;�
<dictcomp>�s

�z.Model._get_field_value_map.<locals>.<dictcomp>)r�rWr\)r:r�r�r8r�r;�_get_field_value_map�s
�zModel._get_field_value_mapcCs(|jdurtd|��t||j��j�S)Nz9Unsaved model instance %r cannot be used in an ORM query.)rr�rqr��get_related_fieldr�)r:r�r8r8r;�prepare_database_save�s

�zModel.prepare_database_savecCr6)aI
        Hook for doing any extra model-wide validation after clean() has been
        called on every field by self.clean_fields. Any ValidationError raised
        by this method will not be associated with a particular field; it will
        have a special-case association with the field defined by NON_FIELD_ERRORS.
        Nr8r9r8r8r;�clean�szModel.cleancCsX|j|d�\}}|�|�}|�|�}|��D]
\}}|�|g��|�q|r*t|��dS)zh
        Check unique constraints on the model and raise ValidationError if any
        failed.
        �r�N)�_get_unique_checks�_perform_unique_checks�_perform_date_checksrp�
setdefault�extendr
)r:r��
unique_checks�date_checks�errors�date_errors�k�vr8r8r;�validate_unique�s

�zModel.validate_uniquecs��durt��g}|j|jjfg}g}|r|j|jjfg}|j��D]}|jjr1|�||jjf�|r@|jjr@|�||jjf�q"|D]\}}|D]}	t�fdd�|	D��s_|�|t|	�f�qIqC|r�|D]\}}
|
D]}t�fdd�|j	D��s�|�||j	f�qkqeg}|j|jj
fg}
|j��D]}|
�||jj
f�q�|
D]R\}}|D]K}|j}|�vr�q�|jr�|�||ff�|j
r�|j
�vr�|�|d||j
f�|jr�|j�vr�|�|d||jf�|jr�|j�vr�|�|d||jf�q�q�||fS)a{
        Return a list of checks to perform. Since validate_unique() could be
        called from a ModelForm, some fields may have been excluded; we can't
        perform a unique check on a model that is missing fields involved
        in that check. Fields that did not validate should also be excluded,
        but they need to be passed in via the exclude argument.
        Nc3��|]}|�vVqdSr�r8�rPrCr�r8r;r^�r�z+Model._get_unique_checks.<locals>.<genexpr>c3r�r�r8r�r�r8r;r^�r��date�year�month)r�r�rW�unique_together�total_unique_constraints�get_parent_listrr�rvr}rzrC�unique�unique_for_date�unique_for_year�unique_for_month)r:r��include_meta_constraintsr��unique_togethers�constraints�parent_class�model_classr��check�model_constraints�
constraintr��fields_with_classr}rdrCr8r�r;r��sd
�
��������zModel._get_unique_checkscCs�i}|D]v\}}i}|D])}|j�|�}t||j�}|dus&|dkr'tjjr'q|jr/|jj	s/q||t
|�<qt|�t|�kr?q|jj
di|��}	|�|j�}
|jj	s\|
dur\|	j|
d�}	|	��rzt|�dkrk|d}nt}|�|g��|�||��q|S)Nr�r#rXrr8)rWr�rqr�r�features�!interprets_empty_strings_as_nullsrEr�r��strr�r�r(rr�rlrr�r�unique_error_message)r:r�r�r��unique_check�
lookup_kwargsr7rd�lookup_valuer��model_class_pk�keyr8r8r;r�s:�

��zModel._perform_unique_checksc
Cs�i}|D]i\}}}}i}t||�}|durq|dkr0|j|d|<|j|d|<|j|d|<nt||�|d||f<t||�||<|jjdi|��}	|jjs[|jdur[|	j	|jd�}	|	�
�rm|�|g��|�
|||��q|S)Nr�z%s__dayz	%s__monthz%s__yearz%s__%sr#r8)rq�dayr�r�r�r(r�r�rr�rlr�r�date_error_message)
r:r�r�r��lookup_typer��
unique_forr�r�r�r8r8r;r�Fs.
���zModel._perform_date_checksc
CsL|j}|�|�}t|jdd|t|j�||t|j�|t|�|�j�d�d�S)Nr�)r�r�r�r��field_label�
date_field�date_field_label��message�code�params)rWr�r
�error_messagesr2�verbose_name)r:r�r7r�r�r�r8r8r;r�es
��zModel.date_error_messagecs�|j�||t�j�|d�}t|�dkr+��|d�}t|j�|d<t|jdd|d�S�fdd�|D�}t|td	��|d
<ttd�d|d�S)
N)r�r�r�r�rXrr�r�r�csg|]
}t��|�j��qSr8)r2r�r�rc�r�r8r;rR�s�z.Model.unique_error_message.<locals>.<listcomp>�and�field_labelsz9%(model_name)s with this %(field_labels)s already exists.r�)	rWr2r�r�r�r
r�r3�_)r:r�r�r�r�r�r8r�r;r�vs.��
��zModel.unique_error_messagecCs>|j|jjfg}|j��D]}|jjr|�||jjf�q
|Sr�)r�rWr�r�r)r:r�r�r8r8r;�get_constraints�s�zModel.get_constraintsc	Cs�|��}tj|j|d�}i}|D]G\}}|D]@}z|j||||d�WqtyV}z't|dd�dkrGt|j�dkrG|�	|jdg��
|�n|�|�}WYd}~qd}~wwq|r^t|��dS)Nr;)r�r/r�r�rXr)r�rrAr��validater
rqr�r}r�r�update_error_dict)	r:r�r�r/r�r�r�r��er8r8r;�validate_constraints�s$
����zModel.validate_constraintsc
Csxi}|dur
t�}nt|�}z|j|d�Wnty-}z|�|�}WYd}~nd}~wwz|��WntyK}z|�|�}WYd}~nd}~ww|r�|D]}|tkr_||vr_|�|�qPz|j|d�Wnty}z|�|�}WYd}~nd}~ww|r�|D]}|tkr�||vr�|�|�q�z|j|d�Wnty�}z|�|�}WYd}~nd}~ww|r�t|��dS)z�
        Call clean_fields(), clean(), validate_unique(), and
        validate_constraints() on the model. Raise a ValidationError for any
        errors that occur.
        Nr�)	r��clean_fieldsr
r�r�rr�r�r�)r:r�r�r�r�r�rCr8r8r;�
full_clean�sR����
���
����zModel.full_cleancCs�|durt�}i}|jjD]<}|j|vrq
t||j�}|jr$||jvr$q
z
t||j|�	||��Wq
t
yI}z|j||j<WYd}~q
d}~ww|rPt
|��dS)z
        Clean all fields and raise a ValidationError containing a dict
        of all validation errors if any occur.
        N)r�rWr}rCrqr��blankrsr�r�r
�
error_list)r:r�r�rd�	raw_valuer�r8r8r;r��s$
���zModel.clean_fieldscKs�g|���|���|jdi|���}|jjsz|�d�pg}|g|jdi|���|���|�|��7}g|�	��|�
��|���|���|�
��R}|�|�|sW|�|���|g|���|���|�|��|���|�|��|���|�|��7}|S)N�	databasesr8)�_check_swappable�_check_model�_check_managersrWrxr��
_check_fields�$_check_m2m_through_same_relationship�_check_long_column_names�_check_id_field�_check_field_name_clashes�#_check_model_name_db_lookup_clashes�3_check_property_name_related_field_accessor_clashes�_check_single_primary_keyr��_check_column_name_clashes�_check_index_together�_check_unique_together�_check_indexes�_check_ordering�_check_constraints�_check_default_pk�_check_db_table_comment)r�r�r�r��clash_errorsr8r8r;r��s\�����������
�������
zModel.checkcCsz|jjs;|jjjr;t|jjt�r|jjjjs;t�	d�s;|jj
r;|jj
js;tj
dtj�d�d|jj
jj�d�|dd�gSgS)N�DEFAULT_AUTO_FIELDzPAuto-created primary key used when not defining a primary key type, by default 'r�z0Configure the DEFAULT_AUTO_FIELD setting or the zh.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.zmodels.W042��hintr��id)rWrVrrhrOr!r�rir�
is_overriddenr��!_is_default_auto_field_overriddenr�Warningr�r�rAr�r8r8r;r�s4���
�	�
���
���zModel._check_default_pkcCsf|jjsgSg}|D]&}t�||�sq
t|}|jjs0d|jjvs0|�t	j
|j�d�|dd��q
|S)N�supports_commentsz8 does not support comments on tables (db_table_comment).zmodels.W046�r�r�)rW�db_table_commentr�allow_migrate_modelrr�r��required_db_featuresrrr��display_name)r�r�r�r�rr8r8r;r�?s&�
���zModel._check_db_table_commentc
Cs�g}|jjrLz
t�|jj�W|Sty(|�tjd|jjdd��Y|St	yK|jj�
d�\}}|�tjd|jj||fdd��Y|Sw|S)z"Check if the swapped model exists.z-'%s' is not of the form 'app_label.app_name'.zmodels.E001�r��.zF'%s' references '%s.%s', which has not been installed, or is abstract.zmodels.E002)rWrxr�	get_modelr�rr�Error�	swappable�LookupError�split)r�r�rXr�r8r8r;r�Vs8���������
zModel._check_swappablecCs:g}|jjr|jjs|jjr|�tjd|jdd��|S)Nz'Proxy model '%s' contains model fields.zmodels.E017r)rWrwrzr{rrrr?�r�r�r8r8r;r�qs��zModel._check_modelcKs,g}|jjD]
}|�|jdi|���q|S)zPerform all manager checks.Nr8)rWr�r�r�)r�r�r�r�r8r8r;r�~szModel._check_managerscKsTg}|jjD]
}|�|jdi|���q|jjD]}|�|jdd|i|���q|S)zPerform all field checks.�
from_modelNr8)rWrzr�r�r{)r�r�r�r�r8r8r;r��szModel._check_fieldscCs�g}g}|jj}dd�|D�}dd�|D�}|D])}|jj||jj|jjf}||vr<|�tjd|jjjj	|dd��q|�|�q|S)zBCheck if no relationship model is used by more than one m2m field.cs�"�|]}t|jjt�r|VqdSr�)rOr�r�rNrcr8r8r;r^��� z=Model._check_m2m_through_same_relationship.<locals>.<genexpr>csr
r�)rOr�r<rNrcr8r8r;r^�rzWThe model has two identical many-to-many relations through the intermediate model '%s'.zmodels.E003r�)
rWr{r�r�r<�through_fieldsrrrrt)r�r��seen_intermediary_signaturesr}rd�	signaturer8r8r;r��s.�
���
z*Model._check_m2m_through_same_relationshipcsH�fdd��jjD�}|r"|djs"�jjjdkr"tjd�dd�gSgS)z%Check if `id` field is a primary key.cs&g|]}|jdkr|�jjkr|�qSr)rCrWrrcr�r8r;rR�s z)Model._check_id_field.<locals>.<listcomp>rr�zP'id' can only be used as a field name if the field also sets 'primary_key=True'.zmodels.E004r�)rWrzrErrCrr)r�r}r8r�r;r��s
���	zModel._check_id_fieldc
CsNg}i}|j��D]:}|jjD]3}|�|j�p|�|j�pd}|r8|�tjd|j|j	j|j|j	jf|dd��|||j<|||j<qq	|j��D]}|j�
�D]}||vr[|||j<qPqI|jjD]C}|�|j�pp|�|j�ppd}|jdko�|o�|jdko�|j	|k}|r�|s�|�tjd|j|j|j	jf|dd��|||j<|||j<qa|S)z2Forbid field shadowing in multi-table inheritance.NzYThe field '%s' from parent model '%s' clashes with the field '%s' from parent model '%s'.zmodels.E005r�r�z;The field '%s' clashes with the field '%s' from model '%s'.zmodels.E006)rWr�rzr�rCr�rrrr��
get_fields)r�r��used_fieldsr�rd�clash�id_conflictr8r8r;r��sR���

�
�� ����
zModel._check_field_name_clashesc	Cs`g}g}|jjD]%}|��\}}|r(||vr(|�tjd|j|fd|dd��q|�|�q|S)Nz>Field '%s' has column name '%s' that is used by another field.z$Specify a 'db_column' for the field.zmodels.E007r�)rWrz�get_attname_columnrrrrC)r��used_column_namesr�rdr��column_namer8r8r;r��s"���
z Model._check_column_name_clashescCsbg}|j}|�d�s|�d�r|�tjd||dd��|St|vr/|�tjd||dd��|S)Nr�zgThe model name '%s' cannot start or end with an underscore as it collides with the query lookup syntax.zmodels.E023r�zbThe model name '%s' cannot contain double underscores as it collides with the query lookup syntax.zmodels.E024)r?�
startswith�endswithrrrr)r�r�r�r8r8r;r�s0�������z)Model._check_model_name_db_lookup_clashescCsTg}|jj}dd�|jjdd�D�}|D]}||vr'|�tjd||dd��q|S)Ncss(�|]}|jr|jdur|��VqdSr�)r+�
related_model�get_attnamercr8r8r;r^3s��
��zLModel._check_property_name_related_field_accessor_clashes.<locals>.<genexpr>F��reversez8The property '%s' clashes with a related field accessor.zmodels.E025r�)rWr��_get_fieldsrrr)r�r�r��related_field_accessors�accessorr8r8r;r�/s$�����z9Model._check_property_name_related_field_accessor_clashescCs8g}tdd�|jjD��dkr|�tjd|dd��|S)Ncss�|]}|jrdVqdS)rXNrVrcr8r8r;r^Gr�z2Model._check_single_primary_key.<locals>.<genexpr>rXzBThe model cannot have more than one field with 'primary_key=True'.zmodels.E026r�)�sumrWrzrrrrr8r8r;r�Ds��zModel._check_single_primary_keycC�tt|jjttf�stjd|dd�gStdd�|jjD��r&tjd|dd�gSg}|jjD]}|�|�	|d��q,|S)	z+Check the value of "index_together" option.z)'index_together' must be a list or tuple.zmodels.E008r�cs� �|]}t|ttf�VqdSr��rOrvr)�rPr}r8r8r;r^_s�
�z.Model._check_index_together.<locals>.<genexpr>z6All 'index_together' elements must be lists or tuples.zmodels.E009�index_together)
rOrWr$rvr)rrr�r��_check_local_fields�r�r�r}r8r8r;r�Ss(�����	zModel._check_index_togethercCr )	z,Check the value of "unique_together" option.z*'unique_together' must be a list or tuple.zmodels.E010r�csr!r�r"r#r8r8r;r^|�
��
�z/Model._check_unique_together.<locals>.<genexpr>z7All 'unique_together' elements must be lists or tuples.zmodels.E011r�)
rOrWr�rvr)rrr�r�r%r&r8r8r;r�ps(�����	zModel._check_unique_togetherc		Cs�g}t�}|jjD]M}|jddks|jd��r'|�tjd|j|dd��t|j�|j	kr@|�tjd|j|j	f|dd��|j
rV|jD]}|�dd	�|�
|�D��qFq	|D]y}t�||�sbqYt|}|jjs�d
|jjvs�tdd	�|jjD��r�|�tjd|jd
|dd��|jjs�d|jjvs�tdd	�|jjD��r�|�tjd|jd|dd��|jjs�d|jjvs�tdd	�|jjD��r�|�tjd|jd|dd��qYdd�|jjD�}|dd�|jjD�7}||7}|�|�|d��|S)z/Check fields, names, and conditions of indexes.rr�z@The index name '%s' cannot start with an underscore or a number.zmodels.E033r�z8The index name '%s' cannot be longer than %d characters.zmodels.E034css�|]}|dVqdS)rNr8)rP�refr8r8r;r^�s�
�z'Model._check_indexes.<locals>.<genexpr>�supports_partial_indexescss�|]}|jduVqdSr�)�	condition�rPr�r8r8r;r^�r�z,%s does not support indexes with conditions.zLConditions will be ignored. Silence this warning if you don't care about it.zmodels.W037r��supports_covering_indexescsr�r���includer+r8r8r;r^�r�z1%s does not support indexes with non-key columns.zQNon-key columns will be ignored. Silence this warning if you don't care about it.zmodels.W040�supports_expression_indexescsr�r�)�contains_expressionsr+r8r8r;r^�r�z+%s does not support indexes on expressions.zKAn index won't be created. Silence this warning if you don't care about it.zmodels.W043cSs g|]}|jD]\}}|�qqSr8)�
fields_orders)rPr�r�r�r8r8r;rR�s
��z(Model._check_indexes.<locals>.<listcomp>cSsg|]
}|jD]}|�qqSr8r-)rPr�r.r8r8r;rR��r�)r�rWr�rC�isdigitrrrr��max_name_lengthr0�expressionsr��_get_expr_referencesrr�rr�r)r�r�r�rr,r/r�r%)	r�r�r��
referencesr��
expressionr�rr}r8r8r;r��s����
���


�������
�����
�������zModel._check_indexescCs�ddlm}i}|jjdd�D]}|||j<t|d�r |||j<qg}|D]R}z||}WntyE|�t	j
d||f|dd��Yq%wt|j|j
�r^|�t	j
d	|||f|d
d��q%||jjvrw|�t	j
d|||jjfd|d
d��q%|S)Nr)�modelsFrr�z*'%s' refers to the nonexistent field '%s'.zmodels.E012r�zV'%s' refers to a ManyToManyField '%s', but ManyToManyFields are not permitted in '%s'.zmodels.E013z;'%s' refers to field '%s' which is not local to model '%s'.z4This issue may be caused by multi-table inheritance.zmodels.E016r�)�	django.dbr9rWrrCrKr�r�rrrrOr��
ManyToManyRelrzr)r�r}�optionr9�forward_fields_mapr�r�r7r8r8r;r%�sd


������
����
����	zModel._check_local_fieldscCs�|jjr
tjd|dd�gS|jjs|jjsgSt|jjttf�s)tjd|dd�gSg}|jj}dd�|D�}dd�|D�}g}g}|D]}t	|vrO|�
|�qC|�
|�qC|}|D]V}|}d	}|�t	�D]J}	z|	d
krp|jj}n|j�
|	�}|jr�|jdjj}nd	}Wqdttfy�|d	us�|�|	�d	ur�|�|	�d	ur�|�
tjd||d
d��YqdwqYdd�|D�}g}
|j}tt�dd�t|j|j�D���}|
�||�|
D]}
|�
tjd|
|d
d��q�|S)ze
        Check "ordering" option -- is it a list of strings and do all fields
        exist?
        z?'ordering' and 'order_with_respect_to' cannot be used together.zmodels.E021r�zQ'ordering' must be a tuple or list (even if you want to order by only one field).zmodels.E014css&�|]}t|t�r|dkr|VqdS)�?N)rOr�rcr8r8r;r^@s�$z(Model._check_ordering.<locals>.<genexpr>css*�|]}|�d�r|dd�n|VqdS)r�rXN)rrcr8r8r;r^Cs�(Nr���zJ'ordering' refers to the nonexistent field, related field, or lookup '%s'.zmodels.E015cSsh|]}|dkr|�qSr#r8rcr8r8r;remsz(Model._check_ordering.<locals>.<setcomp>css4�|]}|jr
|jr|j|jfn|j��fVqdSr�)rh�concreterCr�r��related_query_namercr8r8r;r^vs����

�)rW�_ordering_clashrrr�r`rOr)rvrrrrr�r+�
path_infos�to_optsr�r	�AttributeError�
get_transform�
get_lookupr�r�
from_iterabler}r.r�)r�r�r}�_fields�related_fieldsrdr��_cls�fld�part�invalid_fieldsr��valid_fields�
invalid_fieldr8r8r;r� s�����	
�������
��	���zModel._check_orderingc

CsX|sgSg}d}d}|D],}t�||�sqt|}|j��}|dus&|jjr'q|dur0|}|}q||kr8|}|}q|dur?|S|jjD](}|�	�\}	}
|j
durk|
durkt|
�|krk|�t
jd|
||fd|dd��qC|jjD]9}t|jjt�rzqp|jjjjD](}|�	�\}	}|j
dur�|dur�t|�|kr�|�t
jd|||fd|dd��q�qp|S)	z�
        Check that any auto-generated column names are shorter than the limits
        for each database in which the model will be created.
        Nz\Autogenerated column name too long for field "%s". Maximum length is "%s" for database "%s".z/Set the column name manually using 'db_column'.zmodels.E018r�z`Autogenerated column name too long for M2M field "%s". Maximum length is "%s" for database "%s".z\Use 'through' to create a separate model for M2M and then set column_name using 'db_column'.zmodels.E019)rr�r�opsr4r��truncates_namesrWrzr�	db_columnr�rrrr{rOr�r<r�)
r�r�r��allowed_len�db_aliasr�rr4rdr�r�m2m�rel_namer8r8r;r��st
�
����
�����zModel._check_long_column_namesccs��t|t�r0|jD]$}t|t�r%|\}}t|�t��V|�|�EdHq	|�|�EdHq	dSt|t�r@t|j�t��VdSt	|d�rT|�
�D]}|�|�EdHqIdSdS)N�get_source_expressions)rOr(�childrenrvrrr6r'rCrKrX)r��expr�child�lookuprL�src_exprr8r8r;r6�s �


�

�zModel._get_expr_referencesc

Cs�g}|D�]�}t�||�sqt|}|jjs6d|jjvs6tdd�|jjD��r6|�	t
jd|jd|dd��|jj
sZd|jjvsZtd	d�|jjD��rZ|�	t
jd
|jd|dd��|jjs~d|jjvs~td
d�|jjD��r~|�	t
jd|jd|dd��|jjs�d|jjvs�tdd�|jjD��r�|�	t
jd|jd|dd��|jjs�d|jjvs�tdd�|jjD��r�|�	t
jd|jd|dd��tt�dd�|jjD���}t�}|jjD]�}t|t��r|jj
s�d|jjvr�t|jt�r�|�|�|j��|jj�sd|jjv�r|j�r|jD]}|�|�|���qq�t|t��r\|jj�s.d|jjv�r\t|jt��r>|�|�|j��tdd�|j��D���r\|�	t
jd|j�d�d|dd��q�|D]t^}	}
|	dk�rm|� |	�|
�sr�q_z!|	dk�r}|jj!}n|j�"|	�}|j#�r�|j$�s�|j%�r�W�q_Wnt&�y�Y�q_w|
d}t'|d ��r�t'|d!��r�|�(|�du�r�|�)|�du�r�|�	t
j*d"t+�,|	g|
�|d#d$���q_|�-|�.|d%��q|S)&N� supports_table_check_constraintscs��|]}t|t�VqdSr�)rOr�rPr�r8r8r;r^��
��
�z+Model._check_constraints.<locals>.<genexpr>z&%s does not support check constraints.zOA constraint won't be created. Silence this warning if you don't care about it.zmodels.W027r�r)cs�$�|]
}t|t�o
|jduVqdSr�)rOrr*r`r8r8r;r^	��
�
�z7%s does not support unique constraints with conditions.zmodels.W036�&supports_deferrable_unique_constraintscsrbr�)rOr�
deferrabler`r8r8r;r^ 	rcz2%s does not support deferrable unique constraints.zmodels.W038r,cs� �|]}t|t�o|jVqdSr�)rOrr.r`r8r8r;r^4	r'z<%s does not support unique constraints with non-key columns.zmodels.W039r/csrfr�)rOrr0r`r8r8r;r^G	s�
�
�z6%s does not support unique constraints on expressions.zmodels.W044css,�|]}t|t�rg|j�|j�RVqdSr�)rOrr}r.r`r8r8r;r^Y	s��
�csr_r�)rOr)rPrZr8r8r;r^{	razCheck constraint zS contains RawSQL() expression and won't be validated during the model full_clean().z0Silence this warning if you don't care about it.zmodels.W045rrrFrGz.'constraints' refers to the joined field '%s'.zmodels.E041r�r�)/rr�rr�r^rWr�r�r�rrr�rr)rdr,r/r�rrHrOrr*r(r�r6r0r5rr��flattenrCr�rr�r+�many_to_many�one_to_manyr	rKrFrGrrr�r�r%)
r�r�r�r�rr}r7r�r8r7�lookupsr��first_lookupr8r8r;r��s`
������
������
�������
������
������
����
�
����
���
�
����



��������zModel._check_constraintsr�)NN)FFNN)FFFNN)FNFFNNr)NTT)Gr?r@rAr��classmethodr�r<r>rrrrrrrr�rr r4r6r8r9�alters_datarIrFrOrPr_rcr@rwryr~r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r%r�r�r6r�rTr8r8r�r;r��s�r






H
�6
�

�B%
�Z

6



	
?1 


/
%





	
#

6






Z
6
j
R
r�)�	metaclasscsJ�jj}|�|�}�j�|�jdi|����fdd�t|�D�dg�dS)Ncsg|]
\}}�||d��qS))rrWr8)rPr�r��ordered_objr8r;rR�	r2z$method_set_order.<locals>.<listcomp>rWr8)rWr��get_forward_related_filterr�r'r(�bulk_update�	enumerate)r:rp�id_listr/�	order_wrtrir8ror;�method_set_order�	s
�rvcCs8|jj}|�|�}|jjj}|jjdi|��j|dd�S)NT)�flatr8)rWr�rqrrCr�r(�values_list)r:rpruri�pk_namer8r8r;�method_get_order�	s

rzcCs<t|d|j��tt|��t|d|j��tt|��dS)Nzget_%s_orderzset_%s_order)r�r?�lowerrrzrv)r�rr8r8r;r��	s��r�cCs$t|t�rtj|�}n|}|�|�S)z7Used to unpickle Model subclasses with deferred fields.)rOrvrrrn)�model_idr�r8r8r;r�	s

rTr�)]rjrIr�	functoolsr�	itertoolsr�asgiref.syncrr	�django.appsr�django.confr�django.corer�django.core.exceptionsrr	r
rrr
r:rrrrrr�django.db.modelsrrrrr�django.db.models.constantsr�django.db.models.constraintsrr�django.db.models.deletionrr�django.db.models.expressionsr�django.db.models.fields.relatedr r!r"r#�django.db.models.functionsr$�django.db.models.managerr%�django.db.models.optionsr&�django.db.models.queryr'r(�django.db.models.signalsr)r*r+r,r-�django.db.models.utilsr.r/�django.utils.encodingr0�django.utils.hashabler1�django.utils.textr2r3�django.utils.translationr4r�r5r�rGrMrBrNr�r�r�rvrzr�r�__safe_for_unpickle__r8r8r8r;�<module>st  ]
{