o 3a(@sddlZddlZddlmZmZddlmZmZddlm Z ddl m Z m Z m Z ddlmZddlmZdZe Gd d d Ze Gd d d ZdS) N)flatatt pretty_name)Textarea TextInput)cached_property)conditional_escape format_html html_safe) mark_safe) gettext_lazy) BoundFieldc@seZdZdZddZddZeddZdd Zd d Z d d Z ddZ e ddZ d0ddZd1ddZd1ddZd1ddZe ddZddZd2d d!Zd1d"d#Ze d$d%Ze d&d'Ze d(d)Zed*d+Zd1d,d-Ze d.d/ZdS)3r zA Field plus datacCsj||_||_||_|||_|||_||j|_|jj dur(t ||_ n|jj |_ |j p1d|_ dS)N) formfieldname add_prefix html_nameadd_initial_prefixhtml_initial_nameauto_idhtml_initial_idlabelr help_text)selfrrrr9/usr/lib/python3/dist-packages/django/forms/boundfield.py__init__s     zBoundField.__init__cCs$|jjr||jddS|S)z$Render this field as an HTML widget.T) only_initial)rshow_hidden_initial as_widget as_hiddenrrrr__str__szBoundField.__str__csXjjjdp j}|rd|ini}|}fddjjjj|dDS)a Most widgets yield a single subwidget, but others like RadioSelect and CheckboxSelectMultiple produce one subwidget for each choice. This property is cached so that only one database query occurs when rendering ModelChoiceFields. idcs g|] }tjj|jjqSr) BoundWidgetrwidgetrrenderer).0r%r!rr 0sz)BoundField.subwidgets..)attrs) rr%r)getrbuild_widget_attrs subwidgetsrvalue)rid_r)rr!rr,$s    zBoundField.subwidgetscCsdS)NTrr!rrr__bool__5szBoundField.__bool__cC t|jSN)iterr,r!rrr__iter__9 zBoundField.__iter__cCr0r1)lenr,r!rrr__len__<r4zBoundField.__len__cCs*t|ttfstdt|j|j|S)Nz6BoundField indices must be integers or slices, not %s.) isinstanceintslice TypeErrortype__name__r,)ridxrrr __getitem__?s zBoundField.__getitem__cCs|jj|j|jS)zT Return an ErrorList (empty if there are no errors) for this field. )rerrorsr*r error_classr!rrrr?IszBoundField.errorsNFcCs||p|jj}|jjr d|_|pi}|||}|jr+d|jvr+|d|r'|jn|j|j |r2|j n|j | ||j jdS)z Render the field by rendering the passed widget, adding any HTML attributes passed as attrs. If a widget isn't specified, use the field's default widget. Tr#)rr-r)r&)rr%localize is_localizedr+rr) setdefaultrrenderrrr-rr&)rr%r)rrrrrPs  zBoundField.as_widgetcK|jt|fi|S)zZ Return a string of HTML for representing this as an . )rrrr)kwargsrrras_textdszBoundField.as_textcKrE)z>Return a string of HTML for representing this as a