https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/django/contrib/admin/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/django/contrib/admin/__pycache__/checks.cpython-310.pyc
o

3�a[��@sddlZddlmZddlmZddlmZddlmZm	Z	m
Z
ddlmZddl
mZddlmZdd	lmZdd
lmZddlmZmZmZddlmZdd
lmZddlmZdd�Zdd�Z dd�Z!dd�Z"Gdd�d�Z#Gdd�de#�Z$Gdd�de#�Z%dd�Z&dd �Z'd!d"�Z(dS)#�N)�chain)�apps)�settings)�NotRelationField�flatten�get_fields_from_path)�checks)�FieldDoesNotExist)�models)�
LOOKUP_SEP)�
Combinable)�
BaseModelForm�BaseModelFormSet�_get_foreign_key)�engines)�DjangoTemplates)�
import_stringcCs"zt||�WStyYdSw)zX
    issubclass() variant that doesn't raise an exception if cls isn't a
    class.
    F)�
issubclass�	TypeError)�cls�	classinfo�r�=/usr/lib/python3/dist-packages/django/contrib/admin/checks.py�_issubclasss
�rc	CsFt|�}|D]}zt|�}Wn	tyYqwt||�r dSqdS)z|
    Return whether or not a dotted class path (or a subclass of that class) is
    found in a list of candidate paths.
    TF)r�ImportErrorr)�
class_path�candidate_pathsr�path�
candidate_clsrrr�_contains_subclass!s�
�rcKs.ddlm}g}|D]
}|�|�|��q
|S)Nr��	all_sites)�django.contrib.admin.sitesr!�extend�check)�app_configs�kwargsr!�errors�siterrr�check_admin_app2s
r)c	Ksxddlm}t�d�s
gSg}d}|D]\}}t�|�s*|�tjd|d|d��qt��D]}t	|t
�r;|j}nq/d}|sK|�tjd	d
d��n>d|jvr`t
dtj�r`|�tjd
dd��d|jvro|�tjddd��tdd�|D��}|r�d|jvr�|�tjddd��t
dtj�s�|�tjddd��t
dtj�s�|�tjddd��t
dtj�s�|�tjddd d!��|S)"zF
    Check that the admin's dependencies are correctly installed.
    rr zdjango.contrib.admin))zdjango.contrib.contenttypesi�)zdjango.contrib.authi�)zdjango.contrib.messagesi�zE'%s' must be in INSTALLED_APPS in order to use the admin application.z	admin.E%d)�idNz�A 'django.template.backends.django.DjangoTemplates' instance must be configured in TEMPLATES in order to use the admin application.z
admin.E403z+django.contrib.auth.context_processors.authz)django.contrib.auth.backends.ModelBackendz�'django.contrib.auth.context_processors.auth' must be enabled in DjangoTemplates (TEMPLATES) if using the default auth backend in order to use the admin application.z
admin.E402z3django.contrib.messages.context_processors.messagesz�'django.contrib.messages.context_processors.messages' must be enabled in DjangoTemplates (TEMPLATES) in order to use the admin application.z
admin.E404css�|]}|jVqdS�N)�enable_nav_sidebar)�.0r(rrr�	<genexpr>ms�z%check_dependencies.<locals>.<genexpr>z*django.template.context_processors.requestz�'django.template.context_processors.request' must be enabled in DjangoTemplates (TEMPLATES) in order to use the admin navigation sidebar.z
admin.W411z7django.contrib.auth.middleware.AuthenticationMiddlewarezv'django.contrib.auth.middleware.AuthenticationMiddleware' must be in MIDDLEWARE in order to use the admin application.z
admin.E408z4django.contrib.messages.middleware.MessageMiddlewarezs'django.contrib.messages.middleware.MessageMiddleware' must be in MIDDLEWARE in order to use the admin application.z
admin.E409z4django.contrib.sessions.middleware.SessionMiddlewarezs'django.contrib.sessions.middleware.SessionMiddleware' must be in MIDDLEWARE in order to use the admin application.zInsert 'django.contrib.sessions.middleware.SessionMiddleware' before 'django.contrib.auth.middleware.AuthenticationMiddleware'.z
admin.E410)�hintr*)r"r!r�is_installed�appendr�Errorr�all�
isinstancer�engine�context_processorsrr�AUTHENTICATION_BACKENDS�any�Warning�
MIDDLEWARE)	r&r!r'�app_dependencies�app_name�
error_coder5�django_templates_instance�sidebar_enabledrrr�check_dependencies:s�

���
�
��
���������r@c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7S)8�BaseModelAdminCheckscKs�g|�|��|�|��|�|��|�|��|�|��|�|��|�|��|�|��|�|��|�	|��|�
|��|�|��|�|��Sr+)
�_check_autocomplete_fields�_check_raw_id_fields�
_check_fields�_check_fieldsets�_check_exclude�_check_form�_check_filter_vertical�_check_filter_horizontal�_check_radio_fields�_check_prepopulated_fields�_check_view_on_site_url�_check_ordering�_check_readonly_fields��self�	admin_objr&rrrr$�s6��������	�
���
�zBaseModelAdminChecks.checkc�Dt�jttf�stdd�dd�Stt���fdd�t�j�D���S)zV
        Check that `autocomplete_fields` is a list or tuple of model fields.
        �a list or tuple�autocomplete_fieldsz
admin.E036��option�objr*cs"g|]
\}}���|d|��qS)zautocomplete_fields[%d])�_check_autocomplete_fields_item�r-�index�
field_name�rWrPrr�
<listcomp>�s��zCBaseModelAdminChecks._check_autocomplete_fields.<locals>.<listcomp>)r4rT�list�tuple�must_ber�
from_iterable�	enumerate�rPrWrr\rrB��

�z/BaseModelAdminChecks._check_autocomplete_fieldsc	Cs�z	|jj�|�}Wntyt|||dd�YSw|js,t|tj�s,t	d||dd�S|j
j�|j
j�}|durMtjd|j
jjt|�jf|jdd	�gS|jsctjd
|jjt|�jf|jdd	�gSgS)z�
        Check that an item in `autocomplete_fields` is a ForeignKey or a
        ManyToManyField and that the item has a related ModelAdmin with
        search_fields defined.
        z
admin.E037��fieldrVrWr*�%a foreign key or a many-to-many fieldz
admin.E038rUNzXAn admin for model "%s" has to be registered to be referenced by %s.autocomplete_fields.z
admin.E039�rWr*zR%s must define "search_fields", because it's referenced by %s.autocomplete_fields.z
admin.E040)�model�_meta�	get_fieldr	�refer_to_missing_field�many_to_manyr4r
�
ForeignKeyr`�
admin_site�	_registry�get�remote_fieldrr2�__name__�type�	__class__�
search_fields)rPrWr[�labelrf�
related_adminrrrrX�sD����������z4BaseModelAdminChecks._check_autocomplete_fields_itemcrR)z\ Check that `raw_id_fields` only contains field names that are listed
        on the model. rS�
raw_id_fieldsz
admin.E001rUc3�&�|]\}}���|d|�VqdS)zraw_id_fields[%d]N)�_check_raw_id_fields_itemrYr\rrr.��
��
�z<BaseModelAdminChecks._check_raw_id_fields.<locals>.<genexpr>)r4ryr^r_r`rrarbrcrr\rrC�rdz)BaseModelAdminChecks._check_raw_id_fieldsc	Cs\z	|jj�|�}Wntyt|||dd�YSw|js,t|tj�s,t	d||dd�SgS)z� Check an item of `raw_id_fields`, i.e. check that field named
        `field_name` exists in model `model` and is a ForeignKey or a
        ManyToManyField. z
admin.E002rergz
admin.E003rU)
rirjrkr	rlrmr4r
rnr`�rPrWr[rwrfrrrr{�s�z.BaseModelAdminChecks._check_raw_id_fields_itemcs��jdurgSt�jttf�stdd�dd�S�jr$tjd�jdd�gSt	�j�}t
|�t
t|��kr=tjd	�jd
d�gStt�
��fdd��jD���S)
z� Check that `fields` only refer to existing fields, doesn't contain
        duplicates. Check if at most one of `fields` and `fieldsets` is defined.
        NrS�fieldsz
admin.E004rUz,Both 'fieldsets' and 'fields' are specified.z
admin.E005rhz2The value of 'fields' contains duplicate field(s).z
admin.E006c3s�|]
}���|d�VqdS)r~N��_check_field_spec)r-r[r\rrr.s
��
�z5BaseModelAdminChecks._check_fields.<locals>.<genexpr>)r~r4r^r_r`�	fieldsetsrr2rur�len�setrra)rPrWr~rr\rrD�s,
��
��
�z"BaseModelAdminChecks._check_fieldscsX�jdurgSt�jttf�stdd�dd�Sg�tt����fdd�t�j�D���S)zT Check that fieldsets is properly formatted and doesn't contain
        duplicates. NrSr�z
admin.E007rUc3s(�|]\}}���|d|��VqdS)z
fieldsets[%d]N)�_check_fieldsets_item)r-rZ�fieldset�rW�seen_fieldsrPrrr.!s
��
�z8BaseModelAdminChecks._check_fieldsets.<locals>.<genexpr>)r�r4r^r_r`rrarbrcrr�rrEs

�z%BaseModelAdminChecks._check_fieldsetscst|ttf�std��dd�St|�dkrtd��dd�St|dt�s.tdd	��d
d�Sd|dvr@tjd��jd
d�gSt|ddttf�sUtdd��dd�S|�	t
|dd��t|�tt|��krvtjd��jdd�gStt�
���fdd�|ddD���S)z~ Check an item of `fieldsets`, i.e. check that this is a pair of a
        set name and a dictionary containing "fields" key. rSz
admin.E008rU�zof length 2z
admin.E009��a dictionary�%s[1]z
admin.E010r~z3The value of '%s[1]' must contain the key 'fields'.z
admin.E011rhz%s[1]['fields']z(There are duplicate field(s) in '%s[1]'.z
admin.E012c3s"�|]}���|d��VqdS)z%s[1]["fields"]Nr)r-�fieldset_fields�rwrWrPrrr.Ds
��
�z=BaseModelAdminChecks._check_fieldsets_item.<locals>.<genexpr>)r4r^r_r`r��dictrr2rur#rr�rra)rPrWr�rwr�rr�rr�&s4����

�z*BaseModelAdminChecks._check_fieldsets_itemcs<t|t�rtt����fdd�t|�D���S���|��S)z� `fields` should be an item of `fields` or an item of
        fieldset[1]['fields'] for any `fieldset` in `fieldsets`. It should be a
        field name or a tuple of field names. c3�*�|]\}}���|d�|f�VqdS)z%s[%d]N)�_check_field_spec_itemrYr�rrr.O�
��
�z9BaseModelAdminChecks._check_field_spec.<locals>.<genexpr>)r4r_r^rrarbr�)rPrWr~rwrr�rr�Is


�z&BaseModelAdminChecks._check_field_speccCsp||jvrgSz	|jj�|�}WntygYSwt|tj�r6|jj	jj
s6tjd||f|j
dd�gSgS)NzvThe value of '%s' cannot include the ManyToManyField '%s', because that field manually specifies a relationship model.z
admin.E013rh)�readonly_fieldsrirjrkr	r4r
�ManyToManyFieldrr�through�auto_createdrr2rur}rrrr�Vs&
�
����
z+BaseModelAdminChecks._check_field_spec_itemcCs^|jdurgSt|jttf�stdd|dd�St|j�tt|j��kr-tjd|j	dd�gSgS)	z6 Check that exclude is a sequence without duplicates. NrS�excludez
admin.E014rUz3The value of 'exclude' contains duplicate field(s).z
admin.E015rh)
r�r4r^r_r`r�r�rr2rurcrrrrFrs
��z#BaseModelAdminChecks._check_excludecC� t|jt�stdd|dd�SgS)z+ Check that form subclasses BaseModelForm. r
�formz
admin.E016��parentrVrWr*)rr�r
�must_inherit_fromrcrrrrG�s
�z BaseModelAdminChecks._check_formcrR)z: Check that filter_vertical is a sequence of field names. rS�filter_verticalz
admin.E017rUc3rz)zfilter_vertical[%d]N��_check_filter_itemrYr\rrr.�r|z>BaseModelAdminChecks._check_filter_vertical.<locals>.<genexpr>)r4r�r^r_r`rrarbrcrr\rrH��

�z+BaseModelAdminChecks._check_filter_verticalcrR)z< Check that filter_horizontal is a sequence of field names. rS�filter_horizontalz
admin.E018rUc3rz)zfilter_horizontal[%d]Nr�rYr\rrr.�r|z@BaseModelAdminChecks._check_filter_horizontal.<locals>.<genexpr>)r4r�r^r_r`rrarbrcrr\rrI�r�z-BaseModelAdminChecks._check_filter_horizontalc	CsPz	|jj�|�}Wntyt|||dd�YSw|js&td||dd�SgS)z� Check one item of `filter_vertical` or `filter_horizontal`, i.e.
        check that given field exists and is a ManyToManyField. z
admin.E019reza many-to-many fieldz
admin.E020rU)rirjrkr	rlrmr`r}rrrr��s�z'BaseModelAdminChecks._check_filter_itemc�@t�jt�stdd�dd�Stt���fdd��j��D���S)z, Check that `radio_fields` is a dictionary. r��radio_fieldsz
admin.E021rUc3�4�|]\}}���|d����|d|�VqdS)r�zradio_fields["%s"]N)�_check_radio_fields_key�_check_radio_fields_value�r-r[�valr\rrr.�����
�z;BaseModelAdminChecks._check_radio_fields.<locals>.<genexpr>)r4r�r�r`r^rra�itemsrcrr\rrJ�s

�z(BaseModelAdminChecks._check_radio_fieldsc	Cshz	|jj�|�}Wntyt|||dd�YSwt|tj�s2|js2t	j
d||f|jdd�gSgS)z� Check that a key of `radio_fields` dictionary is name of existing
        field and that the field is a ForeignKey or has `choices` defined. z
admin.E022rezsThe value of '%s' refers to '%s', which is not an instance of ForeignKey, and does not have a 'choices' definition.z
admin.E023rh)rirjrkr	rlr4r
rn�choicesrr2rur}rrrr��s �����z,BaseModelAdminChecks._check_radio_fields_keycCs8ddlm}m}|||fvrtjd||jdd�gSgS)z5 Check type of a value of `radio_fields` dictionary. r)�
HORIZONTAL�VERTICALzDThe value of '%s' must be either admin.HORIZONTAL or admin.VERTICAL.z
admin.E024rh)�django.contrib.admin.optionsr�r�rr2ru)rPrWr�rwr�r�rrrr��s��z.BaseModelAdminChecks._check_radio_fields_valuecCs.t|j�st|jt�stjd|jdd�gSgS)NzBThe value of 'view_on_site' must be a callable or a boolean value.z
admin.E025rh)�callable�view_on_siter4�boolrr2rurcrrrrL�s��z,BaseModelAdminChecks._check_view_on_site_urlcr�)zZ Check that `prepopulated_fields` is a dictionary containing allowed
        field types. r��prepopulated_fieldsz
admin.E026rUc3r�)r�zprepopulated_fields["%s"]N)�_check_prepopulated_fields_key� _check_prepopulated_fields_valuer�r\rrr.�r�zBBaseModelAdminChecks._check_prepopulated_fields.<locals>.<genexpr>)r4r�r�r`r^rrar�rcrr\rrK�s

�z/BaseModelAdminChecks._check_prepopulated_fieldsc	Cslz	|jj�|�}Wntyt|||dd�YSwt|tjtjtj	f�r4t
jd||f|jdd�gSgS)z� Check a key of `prepopulated_fields` dictionary, i.e. check that it
        is a name of existing field and the field is one of the allowed types.
        z
admin.E027rezyThe value of '%s' refers to '%s', which must not be a DateTimeField, a ForeignKey, a OneToOneField, or a ManyToManyField.z
admin.E028rh)
rirjrkr	rlr4r
�
DateTimeFieldrnr�rr2rur}rrrr��s����	z3BaseModelAdminChecks._check_prepopulated_fields_keycsBt|ttf�std��dd�Stt����fdd�t|�D���S)zf Check a value of `prepopulated_fields` dictionary, i.e. it's an
        iterable of existing fields. rSz
admin.E029rUc3r�)z%s[%r]N)�%_check_prepopulated_fields_value_item)r-rZ�
subfield_namer�rrr.r�zHBaseModelAdminChecks._check_prepopulated_fields_value.<locals>.<genexpr>)r4r^r_r`rrarb)rPrWr�rwrr�rr�s

�z5BaseModelAdminChecks._check_prepopulated_fields_valuec	Cs8z
|jj�|�WgStyt|||dd�YSw)z[ For `prepopulated_fields` equal to {"slug": ("title",)},
        `field_name` is "title". z
admin.E030re)rirjrkr	rl�rPrWr[rwrrrr�s��z:BaseModelAdminChecks._check_prepopulated_fields_value_itemcsR�jdurgSt�jttf�stdd�dd�Stt���fdd�t�j�D���S)z= Check that ordering refers to existing fields or is random. NrS�orderingz
admin.E031rUc3rz)zordering[%d]N)�_check_ordering_itemrYr\rrr..r|z7BaseModelAdminChecks._check_ordering.<locals>.<genexpr>)r�r4r^r_r`rrarbrcrr\rrM%s

�z$BaseModelAdminChecks._check_orderingc	Cs�t|ttjf�r t|tj�s|��}t|jtj�r|jj}ngS|dkr6t|j	�dkr6t
jdd|jdd�gS|dkr<gSt
|vrBgS|�d�rM|dd�}|d	krSgSz
|jj�|�WgStynt|||d
d�YSw)z2 Check that `ordering` refers to existing fields. �?r�z^The value of 'ordering' has the random ordering marker '?', but contains other fields as well.z2Either remove the "?", or remove the other fields.z
admin.E032)r/rWr*�-N�pkz
admin.E033re)r4rr
�OrderBy�asc�
expression�F�namer�r�rr2rur�
startswithrirjrkr	rlr�rrrr�3s8
��	
��z)BaseModelAdminChecks._check_ordering_itemcsR�jdkrgSt�jttf�stdd�dd�Stt���fdd�t�j�D���S)zA Check that readonly_fields refers to proper attribute or field. rrSr�z
admin.E034rUc3rz)zreadonly_fields[%d]N)�_check_readonly_fields_itemrYr\rrr.`r|z>BaseModelAdminChecks._check_readonly_fields.<locals>.<genexpr>)r�r4r^r_r`rrarbrcrr\rrNXs

�z+BaseModelAdminChecks._check_readonly_fieldscCszt|�rgSt||�r
gSt|j|�rgSz
|jj�|�WgSty<tjd||jj	|jjj
f|jdd�gYSw)NzSThe value of '%s' is not a callable, an attribute of '%s', or an attribute of '%s'.z
admin.E035rh)r��hasattrrirjrkr	rr2rursrwr�rrrr�es(

������z0BaseModelAdminChecks._check_readonly_fields_itemN)rs�
__module__�__qualname__r$rBrXrCr{rDrEr�r�r�rFrGrHrIr�rJr�r�rLrKr�r�r�rMr�rNr�rrrrrA�s8+ #


%
rAcs�eZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Z�ZS))�ModelAdminCheckscs�gt��|��|�|��|�|��|�|��|�|��|�|��|�|��|�|��|�	|��|�
|��|�|��|�|��|�
|��|�|��|�|��Sr+)�superr$�_check_save_as�_check_save_on_top�_check_inlines�_check_list_display�_check_list_display_links�_check_list_filter�_check_list_select_related�_check_list_per_page�_check_list_max_show_all�_check_list_editable�_check_search_fields�_check_date_hierarchy� _check_action_permission_methods�_check_actions_uniquenessrO�rurrr$�s>
��������	�
���
���zModelAdminChecks.checkcCr�)z Check save_as is a boolean. �	a boolean�save_asz
admin.E101rU)r4r�r�r`rcrrrr���
�zModelAdminChecks._check_save_ascCr�)z! Check save_on_top is a boolean. r��save_on_topz
admin.E102rU)r4r�r�r`rcrrrr��r�z#ModelAdminChecks._check_save_on_topcrR)z' Check all inline model admin classes. rS�inlinesz
admin.E103rUc3rz)zinlines[%d]N)�_check_inlines_item�r-rZ�itemr\rrr.�r|z2ModelAdminChecks._check_inlines.<locals>.<genexpr>)r4r�r^r_r`rrarbrcrr\rr��s

�zModelAdminChecks._check_inlinescCs�z
|jd|j}Wntytjd||jdd�gYSwddlm}t||�s7tjd||jdd�gS|j	sFtjd||jdd�gSt|j	t
j�sWtd	d
||dd�S||j	|j
���S)
z Check one inline model admin. �.z*'%s' must inherit from 'InlineModelAdmin'.z
admin.E104rhr)�InlineModelAdminz#'%s' must have a 'model' attribute.z
admin.E105za Modelz%s.modelz
admin.E106rU)r�rs�AttributeErrorrr2rur�r�rrir
�Modelr`ror$)rPrW�inlinerw�inline_labelr�rrrr��s8���	
����z$ModelAdminChecks._check_inlines_itemcrR)zL Check that list_display only contains fields or usable attributes.
        rS�list_displayz
admin.E107rUc3rz)zlist_display[%d]N)�_check_list_display_itemr�r\rrr.�r|z7ModelAdminChecks._check_list_display.<locals>.<genexpr>)r4r�r^r_r`rrarbrcrr\rr��rdz$ModelAdminChecks._check_list_displaycCs�t|�rgSt||�r
gSz	|jj�|�}Wn2tyHzt|j|�}Wn tyEtj	d|||j
j|jjjf|j
dd�gYYSwYnwt
|tj�r[tj	d||j
dd�gSgS)NzsThe value of '%s' refers to '%s', which is not a callable, an attribute of '%s', or an attribute or method on '%s'.z
admin.E108rhz0The value of '%s' must not be a ManyToManyField.z
admin.E109)r�r�rirjrkr	�getattrr�rr2rursrwr4r
r�)rPrWr�rwrfrrrr��s>

���������z)ModelAdminChecks._check_list_display_itemcspddlm}�jdur
gSt�jttf�stdd�dd�S�jj|jur6tt	�
��fdd	�t�j�D���SgS)
zK Check that list_display_links is a unique subset of list_display.
        r)�
ModelAdminNza list, a tuple, or None�list_display_linksz
admin.E110rUc3rz)zlist_display_links[%d]N)�_check_list_display_links_itemrYr\rrr.r|z=ModelAdminChecks._check_list_display_links.<locals>.<genexpr>)r�r�r�r4r^r_r`�get_list_display�__func__rrarb)rPrWr�rr\rr�s

�z*ModelAdminChecks._check_list_display_linkscCs*||jvrtjd||f|jdd�gSgS)NzIThe value of '%s' refers to '%s', which is not defined in 'list_display'.z
admin.E111rh)r�rr2rur�rrrr�s
���
z/ModelAdminChecks._check_list_display_links_itemcrR)NrS�list_filterz
admin.E112rUc3rz)zlist_filter[%d]N)�_check_list_filter_itemr�r\rrr.$r|z6ModelAdminChecks._check_list_filter.<locals>.<genexpr>)r4r�r^r_r`rrarbrcrr\rr� s

�z#ModelAdminChecks._check_list_filterc	Cs�ddlm}m}t|�r2t|tj�s2t||�std||dd�St	||�r0t
jd||jdd�gSgSt|t
tf�rN|\}}t||�sLtd	d
||dd�SgS|}z	t|j|�WgSttfyrt
jd||f|jd
d�gYSw)aG
        Check one item of `list_filter`, i.e. check if it is one of three options:
        1. 'field' -- a basic field filter, possibly w/ relationships (e.g.
           'field__rel')
        2. ('field', SomeFieldListFilter) - a field-based list filter class
        3. SomeListFilter - a non-field list filter class
        r)�FieldListFilter�
ListFilterr�z
admin.E113r�z:The value of '%s' must not inherit from 'FieldListFilter'.z
admin.E114rhr�r�z
admin.E115zBThe value of '%s' refers to '%s', which does not refer to a Field.z
admin.E116)�django.contrib.adminr�r�r�r4r
�Fieldrr�rrr2rur_r^rrirr	)rPrWr�rwr�r�rf�list_filter_classrrrr�)s>
�
��

�
���z(ModelAdminChecks._check_list_filter_itemcCs&t|jtttf�stdd|dd�SgS)zA Check that list_select_related is a boolean, a list or a tuple. za boolean, tuple or list�list_select_relatedz
admin.E117rU)r4r�r�r^r_r`rcrrrr�\sz+ModelAdminChecks._check_list_select_relatedcCr�)z) Check that list_per_page is an integer. �
an integer�
list_per_pagez
admin.E118rU)r4r��intr`rcrrrr�d�z%ModelAdminChecks._check_list_per_pagecCr�)z- Check that list_max_show_all is an integer. r��list_max_show_allz
admin.E119rU)r4r�r�r`rcrrrr�lr�z)ModelAdminChecks._check_list_max_show_allcrR)zl Check that list_editable is a sequence of editable fields from
        list_display without first element. rS�
list_editablez
admin.E120rUc3rz)zlist_editable[%d]N)�_check_list_editable_itemr�r\rrr.{r|z8ModelAdminChecks._check_list_editable.<locals>.<genexpr>)r4r�r^r_r`rrarbrcrr\rr�trdz%ModelAdminChecks._check_list_editablec	Cs�z	|jj�|�}Wntyt|||dd�YSw||jvr.tjd||f|jdd�gS|j	rB||j	vrBtjd||jdd�gS|jd|krb|j	sb|j	durbtjd	||jdf|jd
d�gS|j
sstjd||f|jdd�gSgS)
Nz
admin.E121rezKThe value of '%s' refers to '%s', which is not contained in 'list_display'.z
admin.E122rhzMThe value of '%s' cannot be in both 'list_editable' and 'list_display_links'.z
admin.E123rz~The value of '%s' refers to the first field in 'list_display' ('%s'), which cannot be used unless 'list_display_links' is set.z
admin.E124zJThe value of '%s' refers to '%s', which is not editable through the admin.z
admin.E125)rirjrkr	rlr�rr2rur��editabler}rrrr��sT�
�����	

����
���
z*ModelAdminChecks._check_list_editable_itemcCs$t|jttf�stdd|dd�SgS)z$ Check search_fields is a sequence. rSrvz
admin.E126rU)r4rvr^r_r`rcrrrr��sz%ModelAdminChecks._check_search_fieldsc	Cs||jdurgSzt|j|j�d}Wnttfy*tjd|j|jdd�gYSwt|t	j
t	jf�s<tdd|dd	�SgS)
zA Check that date_hierarchy refers to DateField or DateTimeField. N���zNThe value of 'date_hierarchy' refers to '%s', which does not refer to a Field.z
admin.E127rhza DateField or DateTimeField�date_hierarchyz
admin.E128rU)
r�rrirr	rr2rur4r
�	DateFieldr�r`)rPrWrfrrrr��s"
����
z&ModelAdminChecks._check_date_hierarchyc		Csr|��}g}|D].\}}}t|d�sq|jD]}d|}t||�s5|�tjd|jj||jf|jdd��qq|S)z�
        Actions with an allowed_permission attribute require the ModelAdmin to
        implement a has_<perm>_permission() method for each permission.
        �allowed_permissionszhas_%s_permissionz/%s must define a %s() method for the %s action.z
admin.E129rh)�_get_base_actionsr�rr1rr2rurs)	rPrW�actionsr'�funcr��_�
permission�method_namerrrr��s,


�����z1ModelAdminChecks._check_action_permission_methodscCs^g}t�dd�|��D��}|��D]\}}|dkr,|�tjd|jj|f|jdd��q|S)z.Check that every action has a unique __name__.css�|]\}}}|VqdSr+r)r-rr�rrrr.�s�z=ModelAdminChecks._check_actions_uniqueness.<locals>.<genexpr>r�zS__name__ attributes of actions defined in %s must be unique. Name %r is not unique.z
admin.E130rh)	�collections�Counterrr�r1rr2rurs)rPrWr'�namesr��countrrrr��s����	z*ModelAdminChecks._check_actions_uniqueness)rsr�r�r$r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��
__classcell__rrr�rr�~s*		$!	32r�csPeZdZ�fdd�Z�fdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	�Z
S)�InlineModelAdminCheckscsV|j}gt��|��|�||��|�||��|�|��|�|��|�|��|�|��Sr+)	�parent_modelr�r$�_check_relation�_check_exclude_of_parent_model�_check_extra�_check_max_num�_check_min_num�_check_formset)rP�
inline_objr&rr�rrr$�s 
�
�
�����zInlineModelAdminChecks.checkcsvt��|�}|r
gS|�||�rgS|jdurgSt||j|jd�}|j|jvr9tj	d|j|j
jf|jdd�gSgS)N��fk_namezVCannot exclude the field '%s', because it is the foreign key to the parent model '%s'.z
admin.E201rh)
r�rFrr�rrirr�rr2rjrwru)rPrWrr'�fkr�rrrs&

����z5InlineModelAdminChecks._check_exclude_of_parent_modelc
CsXzt||j|jd�WgSty+}ztj|jd|jdd�gWYd}~Sd}~ww)Nrrz
admin.E202rh)rrir�
ValueErrorrr2�argsru)rPrWr�errrr(s�&��z&InlineModelAdminChecks._check_relationcCr�)z! Check that extra is an integer. r��extraz
admin.E203rU)r4rr�r`rcrrrr0r�z#InlineModelAdminChecks._check_extracC�.|jdurgSt|jt�stdd|dd�SgS)z# Check that max_num is an integer. Nr��max_numz
admin.E204rU)rr4r�r`rcrrrr8�

z%InlineModelAdminChecks._check_max_numcCr)z# Check that min_num is an integer. Nr��min_numz
admin.E205rU)r r4r�r`rcrrrrBrz%InlineModelAdminChecks._check_min_numcCr�)z2 Check formset is a subclass of BaseModelFormSet. r�formsetz
admin.E206r�)rr!rr�rcrrrrLr�z%InlineModelAdminChecks._check_formset)rsr�r�r$rrrrrrrrrr�rr
�s

r
cC�tjd||f|j|d�gS)NzThe value of '%s' must be %s.rh�rr2ru)rtrVrWr*rrrr`U�
��r`cCr")Nz)The value of '%s' must inherit from '%s'.rhr#r�rrrr�_r$r�cCs$tjd|||jjjf|j|d�gS)NzDThe value of '%s' refers to '%s', which is not an attribute of '%s'.rh)rr2rirjrwrurerrrrlis���rl))r�	itertoolsr�django.appsr�django.confr�django.contrib.admin.utilsrrr�django.corer�django.core.exceptionsr	�	django.dbr
�django.db.models.constantsr�django.db.models.expressionsr�django.forms.modelsr
rr�django.templater�django.template.backends.djangor�django.utils.module_loadingrrrr)r@rAr�r
r`r�rlrrrr�<module>s<XoX


https://t.me/RX1948 - 2025