
    h=                         S r SSKrSSKrSSKJrJr  SSKJr  SSKJ	r	J
r
Jr  SSKJrJr  SSKJr  SSKJr  SS	KJr  S
SKJr  Sr " S S\5      r " S S\5      r " S S\\S9rg)z
Form classes
    N)NON_FIELD_ERRORSValidationError)Field)	ErrorDict	ErrorListRenderableFormMixin)MediaMediaDefiningClass)MultiValueDict)cached_property)gettext   )get_default_renderer)BaseFormFormc                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )DeclarativeFieldsMetaclass   z,Collect Fields declared on the base classes.c                   > [        UR                  5       5       VVs0 s H-  u  pE[        U[        5      (       d  M  XCR	                  U5      _M/     snnUS'   [
        T
U ]  XX#5      n0 n[        UR                  5       Ho  n[        US5      (       a  UR                  UR                  5        UR                  R                  5        H"  u  pUb  M
  X;   d  M  UR	                  U	5        M$     Mq     Xvl        Xvl        U$ s  snnf )Ndeclared_fields)listitems
isinstancer   popsuper__new__reversed__mro__hasattrupdater   __dict__base_fields)mcsnamebasesattrskeyvalue	new_classr   baseattr	__class__s             D/var/www/html/env/lib/python3.13/site-packages/django/forms/forms.pyr   "DeclarativeFieldsMetaclass.__new__   s     #5;;=1$
1
%'  C31$
  GOCu<	 Y../Dt.//&&t';';<  $}}224=T%<#''-  5 0 !0$3!/$
s
   DD )__name__
__module____qualname____firstlineno____doc__r   __static_attributes____classcell__)r,   s   @r-   r   r      s    6     r   c                   *   \ rS rSrSrSrSrSrSrSr	Sr
SrSrS	rSSS
SS\SSSSS4S jrS rS rS rS rS r\S 5       rS rS rS rS r\S 5       rS rS rS rS)S jrS r S r!S r"S r#S  r$S! r%\&S" 5       r'\S# 5       r(S$ r)S% r*S& r+S' r,S(r-g)*r   4   z
The main implementation of all the Form logic. Note that this class is
different than Form. See the comments by the Form class for more info. Any
improvements to the form API should be made to this class, not to the Form
class.
NTzdjango/forms/div.htmlzdjango/forms/p.htmlzdjango/forms/table.htmlzdjango/forms/ul.htmlzdjango/forms/label.htmlzid_%sFc                    US L=(       d    US LU l         Uc
  [        5       OUU l        Uc
  [        5       OUU l        X0l        Ub  X@l        U=(       d    0 U l        X`l        Ub  UO
[        S5      U l	        Xl
        S U l        [        R                  " U R                  5      U l        0 U l        U R#                  U	c  U R$                  OU	5        U
b  Xl        U R                  (       a  U R&                  (       a  [)        S5      eUcJ  U R*                  c  [-        5       nO2U R*                  n[/        U R*                  [0        5      (       a  U" 5       nXl        g )N:zNThe empty_permitted and use_required_attribute arguments may not both be True.)is_boundr   datafilesauto_idprefixinitialerror_class_label_suffixempty_permitted_errorscopydeepcopyr"   fields_bound_fields_cacheorder_fieldsfield_orderuse_required_attribute
ValueErrordefault_rendererr   r   typerenderer)selfr=   r>   r?   r@   rA   rB   rD   rE   rL   rM   rQ   s               r-   __init__BaseForm.__init__G   s+    D(=E,=(,N$$	).^%E
 K}"&,8,DL!C&. mmD$4$45#% k.A$**{S!-*@'D$?$?$  $$,/100d33T::'zH r7   c                     Uc  g0 nU H!  n U R                   R                  U5      X#'   M#     UR                  U R                   5        X l         g! [         a     MT  f = f)a  
Rearrange the fields according to field_order.

field_order is a list of field names specifying the order. Append fields
not included in the list in the default order for backward compatibility
with subclasses not overriding field_order. If field_order is None,
keep all fields in the order defined in the class. Ignore unknown
fields in field_order to allow disabling fields in form subclasses
without redefining ordering.
N)rI   r   KeyErrorr    )rR   rL   rI   r'   s       r-   rK   BaseForm.order_fields   s`     C"kkooc2 
 	dkk"  s   A
AAc                     U R                   c  SnO$U R                  =(       a    U R                   (       + nSU R                  R                  U R                  USR	                  U R
                  5      S.-  $ )NUnknownz?<%(cls)s bound=%(bound)s, valid=%(valid)s, fields=(%(fields)s)>;)clsboundvalidrI   )rF   r<   r,   r0   joinrI   )rR   is_valids     r-   __repr__BaseForm.__repr__   s`    << H}}9T\\)9HP>>**]]hht{{+	T
 
 	
r7   c              #   B   #    U R                    H  nXU   4v   M     g7f)z8Yield (name, bf) pairs, where bf is a BoundField object.NrI   rR   r$   s     r-   _bound_itemsBaseForm._bound_items   s      KKDT
""  s   c              #   >   #    U R                    H	  nX   v   M     g7f)z.Yield the form's fields as BoundField objects.Nrc   rd   s     r-   __iter__BaseForm.__iter__   s     KKD*  s   c                 R    U R                   U   nXR                  ;  a  UR                  X5      U R                  U'   U R                  U   $ ! [         aO    [        SU< SU R                  R                  < SSR	                  [        U R                   5      5      < S35      ef = f)z(Return a BoundField with the given name.zKey 'z' not found in 'z'. Choices are: z, .)rI   rV   r,   r0   r^   sortedrJ   get_bound_field)rR   r$   fields      r-   __getitem__BaseForm.__getitem__   s    
	KK%E ///-2-B-B4-ND$$T*''--  	 NN++IIfT[[12	 	s   A AB&c                 T    U R                   c  U R                  5         U R                   $ )z7Return an ErrorDict for the data provided for the form.)rF   
full_cleanrR   s    r-   errorsBaseForm.errors   s"     <<OO||r7   c                 J    U R                   =(       a    U R                  (       + $ )z:Return True if the form has no errors, or False otherwise.)r<   rt   rs   s    r-   r_   BaseForm.is_valid   s    }}0T[[0r7   c                 N    U R                   (       a  U R                   < SU< 3$ U$ )zp
Return the field name with a prefix appended, if this Form has a
prefix set.

Subclasses may wish to override.
-)r@   rR   
field_names     r-   
add_prefixBaseForm.add_prefix   s     7;kk$++z2QzQr7   c                 *    SU R                  U5      -  $ )z<Add an 'initial' prefix for checking dynamic initial values.z
initial-%s)r|   rz   s     r-   add_initial_prefixBaseForm.add_initial_prefix   s    dooj999r7   c                 P    UR                  U R                  U R                  U5      $ N)value_from_datadictr=   r>   )rR   widget	html_names      r-   _widget_data_valueBaseForm._widget_data_value   s!     ))$))TZZKKr7   c                 .    U R                   R                  $ r   )rQ   form_template_namers   s    r-   template_nameBaseForm.template_name   s    }}///r7   c           
         / n/ nU R                  5       R                  5       nU R                  5        H  u  pEUR                  (       a\  UR                  (       a8  UUR                   Vs/ s H  n[        S5      U[        U5      S.-  PM     sn-  nUR                  U5        Mr  UR                  XUR                  45        M     U UUUS.$ s  snf )Nz!(Hidden field %(name)s) %(error)s)r$   error)formrI   hidden_fieldsrt   )non_field_errorsrG   re   	is_hiddenrt   rC   strappend)rR   rI   r   
top_errorsr$   bfes          r-   get_contextBaseForm.get_context   s    **,113
))+HD||99 "$# "+A =>#'#a&9:!*# J
 $$R(r99o. , * 	
 	
#s   )$Cc                 r    U R                   R                  [        U R                  SU R                  S95      $ )z
Return an ErrorList of errors that aren't associated with a particular
field -- i.e., from Form.clean(). Return an empty ErrorList if there
are none.
nonfieldrB   rQ   )rt   getr   rB   rQ   rs   s    r-   r   BaseForm.non_field_errors   s3     {{dmmL
 	
r7   c                    [        U[        5      (       d  [        U5      n[        US5      (       a  Ub  [        S5      eUR                  nOU=(       d    [
        UR                  0nUR                  5        H  u  pXR                  ;  a  U[
        :w  a7  XR                  ;  a(  [        SU R                  R                  < SU< S35      eU[
        :X  a(  U R                  SU R                  S9U R                  U'   O&U R                  U R                  S	9U R                  U'   U R                  U   R!                  U5        XR"                  ;   d  M  U R"                  U	 M     g)
a  
Update the content of `self._errors`.

The `field` argument is the name of the field to which the errors
should be added. If it's None, treat the errors as NON_FIELD_ERRORS.

The `error` argument can be a single error, a list of errors, or a
dictionary that maps field names to lists of errors. An "error" can be
either a simple string or an instance of ValidationError with its
message attribute set and a "list or dictionary" can be an actual
`list` or `dict` or an instance of ValidationError with its
`error_list` or `error_dict` attribute set.

If `error` is a dictionary, the `field` argument *must* be None and
errors will be added to the fields that correspond to the keys of the
dictionary.

error_dictNzbThe argument `field` must be `None` when the `error` argument contains errors for multiple fields.'z' has no field named 'z'.r   r   )rQ   )r   r   r   	TypeErrorr   r   
error_listr   rt   rI   rN   r,   r0   rB   rQ   rF   extendcleaned_data)rR   rn   r   r   s       r-   	add_errorBaseForm.add_error   s;   $ %11 $E*E5,'' D 
 ((..0@0@AE!&EKK',,kk1I$>>22E;  ,,*.*:*:$. +; +DLL' +/*:*:DMM*:*RDLL'LL&&z2)))%%e, "/r7   c                    ^ XR                   ;   =(       a;    TS L =(       d0    [        U4S jU R                   R                  5       U    5       5      $ )Nc              3   @   >#    U  H  oR                   T:H  v   M     g 7fr   )code).0r   r   s     r-   	<genexpr>%BaseForm.has_error.<locals>.<genexpr>5  s     P3O%::%3Os   )rt   anyas_data)rR   rn   r   s     `r-   	has_errorBaseForm.has_error2  sD    # 
DL QP4;;3F3F3H3OPP	
r7   c                    [        5       U l        U R                  (       d  g0 U l        U R                  (       a  U R                  5       (       d  gU R                  5         U R                  5         U R                  5         g)zI
Clean all of self.data and populate self._errors and self.cleaned_data.
N)	r   rF   r<   r   rE   has_changed_clean_fields_clean_form_post_cleanrs   s    r-   rr   BaseForm.full_clean8  s_     !{}} (8(8(:(:r7   c                 N   U R                  5        Hh  u  pUR                  n UR                  U5      U R                  U'   [	        U SU-  5      (       a$  [        U SU-  5      " 5       nX@R                  U'   Mh  Mj     g ! [         a  nU R                  X5         S nAM  S nAff = f)Nzclean_%s)re   rn   _clean_bound_fieldr   r   getattrr   r   )rR   r$   r   rn   r(   r   s         r-   r   BaseForm._clean_fieldsI  s    ))+HDHHE(*/*B*B2*F!!$'4d!233#D*t*;<>E.3%%d+ 4	 , # (t''(s   AA>>
B$BB$c                      U R                  5       nUb  Xl        g g ! [         a  nU R                  S U5         S nAg S nAff = fr   )cleanr   r   r   )rR   r   r   s      r-   r   BaseForm._clean_formT  sH    	1::<L '$0! (  	$NN4##	$s    
A>Ac                     g)z
An internal hook for performing additional cleaning after form cleaning
is complete. Used for model validation in model forms.
Nr/   rs   s    r-   r   BaseForm._post_clean]  s    
 	r7   c                     U R                   $ )a  
Hook for doing any extra form-wide cleaning after Field.clean() has been
called on every field. Any ValidationError raised by this method will
not be associated with a particular field; it will have a special-case
association with the field named '__all__'.
)r   rs   s    r-   r   BaseForm.cleand  s        r7   c                 ,    [        U R                  5      $ )z)Return True if data differs from initial.)boolchanged_datars   s    r-   r   BaseForm.has_changedm  s    D%%&&r7   c                     U R                  5        VVs/ s H  u  pUR                  5       (       d  M  UPM      snn$ s  snnf r   )re   _has_changed)rR   r$   r   s      r-   r   BaseForm.changed_dataq  s0    %)%6%6%8N%8BOO<M%8NNNs   ==c                     [        5       nU R                  R                  5        H  nXR                  R                  -  nM     U$ )z=Return all media required to render the widgets on this form.)r	   rI   valuesr   media)rR   r   rn   s      r-   r   BaseForm.mediau  s9     [['')E\\'''E *r7   c                 V    [        S U R                  R                  5        5       5      $ )zc
Return True if the form needs to be multipart-encoded, i.e. it has
FileInput, or False otherwise.
c              3   L   #    U  H  oR                   R                  v   M     g 7fr   )r   needs_multipart_form)r   rn   s     r-   r   (BaseForm.is_multipart.<locals>.<genexpr>  s     WBV<<44BVs   "$)r   rI   r   rs   s    r-   is_multipartBaseForm.is_multipart}  s"    
 W$++BTBTBVWWWr7   c                 V    U  Vs/ s H  oR                   (       d  M  UPM     sn$ s  snf )zq
Return a list of all the BoundField objects that are hidden fields.
Useful for manual form layout in templates.
r   rR   rn   s     r-   r   BaseForm.hidden_fields  s     
 $(;4%??4;;;   &&c                 V    U  Vs/ s H  oR                   (       a  M  UPM     sn$ s  snf )zl
Return a list of BoundField objects that aren't hidden fields.
The opposite of the hidden_fields() method.
r   r   s     r-   visible_fieldsBaseForm.visible_fields  s     
 $(?4%4???r   c                 0   U R                   R                  X!R                   5      n[        U5      (       a  U" 5       n[        U[        R                  [        R
                  45      (       a*  UR                  R                  (       d  UR                  SS9nU$ )z~
Return initial data for field on form. Use initial data from the form
or the field, in that order. Evaluate callable values.
r   )microsecond)	rA   r   callabler   datetimetimer   supports_microsecondsreplace)rR   rn   r{   r(   s       r-   get_initial_for_fieldBaseForm.get_initial_for_field  sl    
   ]];E??GE ux00(--@AALL66MMaM0Er7   )rJ   rF   r?   r   r=   rE   rB   rI   r>   rA   r<   rD   r@   rQ   rM   r   ).r0   r1   r2   r3   r4   rO   rL   r@   rM   template_name_divtemplate_name_ptemplate_name_tabletemplate_name_ultemplate_name_labelr   rS   rK   r`   re   rh   ro   propertyrt   r_   r|   r   r   r   r   r   r   r   rr   r   r   r   r   r   r   r   r   r   r   r   r   r5   r/   r7   r-   r   r   4   s/    KF!/+O3-3 #6!p,

#

."  1R:L 0 0
,	
1-f
"	(1!' O O  X<@r7   r   c                       \ rS rSrSrSrg)r   i  z3A collection of Fields, plus their associated data.r/   N)r0   r1   r2   r3   r4   r5   r/   r7   r-   r   r     s    9r7   r   )	metaclass)r4   rG   r   django.core.exceptionsr   r   django.forms.fieldsr   django.forms.utilsr   r   r   django.forms.widgetsr	   r
   django.utils.datastructuresr   django.utils.functionalr   django.utils.translationr   rC   	renderersr   __all__r   r   r   r/   r7   r-   <module>r      s^      D % H H : 6 3 1 +
!3 >m" m`:89 :r7   